Network Error (React-Native, Express,Nodejs,MongoDB)

社会主义新天地 提交于 2021-02-10 15:10:48

问题


I am getting a Network Error while calling my server(nodejs) API.

I have rechecked my localhost, server, and port. They are all working fine. I have also confirmed using POSTMAN and also ran the server on the web locally to fetch data.

I think I have also added the cors properly in my server.js file.

Want some help on this.

I have also tried with dummy API and they worked fine.

My imports from front-end

Here is LogCat

Response Header in Postman

ngrok status


回答1:


Hi I think you can try exposing your local host to the internet using a service like ngrok which will generate a url for you, and then try using the url to send requests instead of localhost:3000. Simply download and follow the instructions here: https://ngrok.com/docs




回答2:


It seems that you are having a problem in react native code, not in backend. That's why you are not getting any error in postman.

I am guessing that you are importing the dependencies is problematic way.



来源:https://stackoverflow.com/questions/62550990/network-error-react-native-express-nodejs-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!