I'm trying to make a request from my ExpoApp (react Native) to my server Heroku (Signup via a email and password and it should give me a token in return). Actually it's working with postman and save the user perfectly through my database Mongo.But from my ExpoApp (through my Android phone) in my Terminal it doesn't work (i have Error network in my console.log ). Someone can tell me why?
this is my index from my server:
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const authRoutes = require('./routes/authRoutes');
const trackRoutes = require('./routes/trackRoutes');
const requireAuth = require('./middlewares/requireAuth');
const keys = require('./config/keys');
const cors = require('cors');
const app = express()
app.use(bodyParser.json());
app.use(cors());
app.use(authRoutes);
app.use(trackRoutes);
const mongoUri = keys.mongoURI
mongoose.connect(mongoUri, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
})
.....
this is my ExpoApp:
const signup = dispatch => {
return async ({ email, password }) => {
// make api request to sign up with email and password
//if we sign up , modify our state, and say that we are authenticated
// if signing up fails, we probably nedd to reflect an error message
// somewhere
try{
const response = await trackerApi.post('/signup', {email, password});
console.log(response.data); // log Error Network with expo but not with postman
}catch(err){
console.log(err.message)
}
}
};
Request with postman:

