I am not able to transfer user input which is stored in a AsyncStorage to my MongoDB database I have a MongoDB database which I start from the terminal. The console output is the following so there should not be any problems:
Server started on PORT 5000 MongoDB Connected cluster0-shard-00-02.mhqqx.mongodb.net
After this I open my React Native app with expo go and go to my register screen where a new user profile should be created. I store every required user input (name, email, etc.) in a AsyncStorage in JSON format like this:
const nameString = JSON.stringify(name)
const emailString = JSON.stringify(email)
AsyncStorage.setItem('nameInput', nameString);
AsyncStorage.setItem('emailInput', emailString);
setName('');
setEmail('');
When I print the values of the AsyncStorages in the console, there is no error and the data is displayed correctly. So the user inputs are stored in the AsyncStorages.
But after this I try to transfer the AsyncStorage data to my MongoDB database by triggering the following function with a button onPress call:
const submitHandler = async (e) => {
if(password !==confirmpassword) {
setMessage('Passwords do not match')
} else {
setMessage(null)
try {
const config = {
headers: {
"Content-type": "application/json",
},
};
setLoading(true);
const { data } = await axios.post(
"/api/users",
{name, email, password},
config
);
setLoading(false);
} catch (error) {
setError(error.response.data.message);
}
}
console.log(email);
};
When I check the database, no new information is displayed in my database. The database is functional and the route which is defined should be correct. What could be the problem?
I am also able to create a new user from Postman like this:

I have tried to search some answers for this problem for a while now but without success. Help would be much appreciated!
You can do something like
await axios.post("/api/users",
{name, email, password},config)
.then(res=> console.log(res)
.catch(err => console.log("api error", err)
And see what you get in your corresponding terminal.
Note
Your API endpoint(api/users) is not valid. Add the same URL from Postman which you're using.