I've tried on 3 different projects now to make fetch or axios work and I can't. I have tried changing the android manifest like some people tried in some issues but it doesn't work. Not with await/async, not with promises, not even this super simple example. Not even the finally gets called.
It doesn't return errors, or logs, or anything, nothing happens.
After further testing, it looks like Mac/IOS works, but Windows/Android doesn't.
/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow strict-local */import React, {useEffect} from 'react';import {SafeAreaView, Text} from 'react-native';const App = () => { useEffect(() => { console.log('hola'); fetch('http://jsonplaceholder.typicode.com/albums') .then(response => { console.log('Hola'); console.log(response.json()); }) .then(json => console.log(json)) .catch(error => console.error(error)) .finally(() => console.log('Finally')); }, []); return (<SafeAreaView><Text>Hola</Text></SafeAreaView> );};export default App;
This is the package.json:
{"name": "prueba","version": "0.0.1","private": true,"scripts": {"android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","test": "jest","lint": "eslint ." },"dependencies": {"axios": "^0.21.1","react": "17.0.1","react-native": "0.64.1" },"devDependencies": {"@babel/core": "^7.12.9","@babel/runtime": "^7.12.5","@react-native-community/eslint-config": "^2.0.0","babel-jest": "^26.6.3","eslint": "7.14.0","jest": "^26.6.3","metro-react-native-babel-preset": "^0.64.0","react-test-renderer": "17.0.1" },"jest": {"preset": "react-native" }}