react-native: [TypeError: Network request failed] either with fetch API or axios on android
I have a problem with fetching an API on my code I use both fetch and axios but the result is same:
[type error: Network request failed]
here is my code for fetch:
useEffect(() => { fetch('https://jsonplaceholder.typicode.com/users') .then((res) => res.json()) .then((data) => { console.log(data) }) .catch((err) => console.log(err)) }, []);
I don’t use an emulator because my CPU doesn’t support vt-x. so I use a Xperia TX which has android 4.3 and I connect it over Wi-Fi to see my result. it work properly so far but the only problem is this API fetching.
React Native version:
0.63.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 24 (1 by maintainers)
Still I have this issue. Sometimes my https api works and sometimes it throws [TypeError: Network request failed]
IOS is working fine but not android
how? i have same problems
@gvsakhil , can u please let me know the steps to install SSL certificate in Android & iOS?
Hi @SohaibKtb @akeuk The issue got resolved for me after correctly installing the SSL Certificate.
same here, those api’s are so unstable on android: i have another similar problem with them: https://github.com/facebook/react-native/issues/29267