'React Native Possible Unhandled Promise Error with axios
I am trying to fetch two different api with axios and use it on different flatlist
I'm getting this error:
[Unhandled promise rejection: Error: Request failed with status code 429]
Possible Unhandled Promise Rejection (id: 28)
Here's the my code
const [data, setData] = React.useState([]);
const [data1, setData1] = React.useState([]);
axios.all([
axios.get('https://jsonplaceholder.typicode.com/nation'),
axios.get('https://jsonplaceholder.typicode.com/state')
])
.then(responseArr => {
setData(responseArr[0].data);
setData1(responseArr[1].data);
});
return (
<View style={styles.container}>
<View >
<FlatList
data={data}
listKey="nation"
keyExtractor={item => item.id}
showsVerticalScrollIndicator = {false}
renderItem={({item}) => {
return (
<View>
<Text>{item.event_id}</Text>
</View>
)
}}
/>
</View>
<View style={{ marginTop: 30 }}>
<FlatList
data={data1}
listKey="state"
keyExtractor={item => item.id}
showsVerticalScrollIndicator = {false}
renderItem={({item}) => {
return (
<View>
<Text>{item.venue_id}</Text>
</View>
)
}}
/>
</View>
</View>
);
};
Thank for your help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
