I have a POST request: ' https://mysterious-reef-29460.herokuapp.com/api/v1/validate '
To get an answer, I have to pass such data:
email: 'max@test.com', password: '12345', content-type: 'application/json' I tried to do this:
const status = response => { if (response.status !== 200) { return Promise.reject(new Error(response.statusText)) } return Promise.resolve(response) } const json = response => { console.log(response.headers.get('content-type')); return response.json() } fetch('https://mysterious-reef-29460.herokuapp.com/api/v1/validate', { method: 'post', body: 'test=1', headers: { 'email': 'max@test.com', 'password': '12345', } }) .then(status) .then(json) .then(data => { console.log('data', data); }) .catch(error => { console.log('error', error); }) But it returns: {status: "err", message: "wrong_email_or_password"}