I have an API in Node, to which I want to communicate from the front using React. The thing is, when logging in from the front (with the correct credentials, tested in Postman) I get the following response (instead of the token):
Response {type: "cors", url: "http://localhost:3001/api/auth/login", redirected: false, status: 200, ok: true, …}
body: (...)
bodyUsed: true
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "http://localhost:3001/api/auth/login"
**API code:
index.js:
const express = require('express');
const app = express();
const cors = require('cors');
//Config
app.set('port', 3001)
//Middlewares
app.use(express.json());
app.use(cors());
//Routes
app.use(require('./routes/users'));
app.use(require('./routes/auth'));
app.use(require('./routes/tickets'));
//Server
app.listen(app.get('port'), () =>{
console.log('Server listen on port', app.get('port'));
})
What am I doing wrong?