I’m currently creating a Todo-list app with React Native with MongoDB where I’m running the app on my Expo Go app on my iPhone. I’m trying to register the user on the registration page whereby the data is then sent via Axios and received by my backend but MongoDB does not receieve the data and hence is unable to store it in the database. I have tested both the registering and the connection to mongoDB, the app returns me the alert whereby the user is successfully registered and my console tells me that I’m successfully connected to mongoDB.
I suspect that it might be due to the difference in ports as my mongoDB is running on port 3000 while my expo go is on port 8081, I've tried playing around with the ports but my registration is only successful on port 8081 and I am unable to change my mongoDB port to 8081 as they can't run on the same port. I've imported cors to deal with this but still to no avail. Here are my code for the axios posting as well as my mongoDB connection.
Note that my ip is removed in the axios post code image as well as my database link in mongoose connect for the backend code for privacy.
[axios.post](https://i.sstatic.net/QSDUpsEn.png)
[backend part1](https://i.sstatic.net/QSs7hgnZ.png)
[backend part2](https://i.sstatic.net/F0zLtzXV.png)
Darrenn Ang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.