Skip to content

Error 400 Bad Request Question #27

@davStar

Description

@davStar

Hello json-server-auth team,

Context:
Receive 400 error so I can understand I send a bad request. However seems everything fine in my side. So please tell me if I miss something.

My log track the following output:
POST /login 400 1.362 ms - 20

Code:
Request API url :

`
const authEndpoint = "http://localhost:3000/login"

fetch(authEndpoint, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',

  },
  body: JSON.stringify({
    email: this.state.email,
    password: this.state.password,
  }),
}).then((response) => {
  console.log(response.status)
  response.status})
  .catch((error) => {
    console.error(error);
 });`

My db.json config file:

`
{
"signal": [
{ "id": 1, "category": "Fuite d'eau", "user": "[email protected]", "description": "Fuite d'eau issuen de l'étage 2" }
],

"login":[
    {"email": "[email protected]", "name": "David", "lastname": "M", "password":"test"},
    {"email": "[email protected]", "name": "David", "lastname": "M", "password":"weloveyou"},
    {"email": "remi@test",  "name": "Remi", "lastname": "P", "password":"weloveyou"},
    {"email": "thomas@test",  "name": "Thomas", "lastname": "S", "password":"weloveyou"}


]

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions