Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30336

Returning null is not an object React-native, "http request"

$
0
0

Hi i'm using Android device (no emulator) and I'm trying to get data form api with axios request but it return "null is not an object" even if I set state. I also can't retrieve data from IP address (localhost) I need to check de API version of my device and I don't know how to do that...I already try to change the "Android Manifest files but still giving me request network fail".. So Which android emulator allows http (localhost) request?? Thanks

This is my simple code:

import React from 'react';import { StyleSheet, View, Text, FlatList} from 'react-native';import axios from 'axios';class App extends React.Component {    state = {        url: 'https://raw.githubusercontent.com/Hardeepcoder/fake_json/master/Users',        users: null,    };async componentDidMount(){    const res = await axios.get(this.state.url);    this.setState({users: res.data['results']});}render () {return (<React.Fragment><View>{this.state.users.map(users => (<Text>{users.name}</Text>    ))}<Text>Welcome to bchef</Text><View><Text>Hola</Text></View></View></React.Fragment>);}};const styles = StyleSheet.create({});export default App;

Viewing all articles
Browse latest Browse all 30336

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>