I have got problem with Fetch in React, I'm using this code, and i should recive this status http://docs.recruitment-api.pyt1.stg.jmr.pl/# But i receive Succes: {"message":"The method is not allowed for the requested URL."} with Status 200 OK Also methods change to OPTIONS http://prntscr.com/lu0lat
submitToApi = e => {
e.preventDefault();
const url =
'https://cors-anywhere.herokuapp.com/http://recruitment-api.pyt1.stg.jmr.pl/login';
const data = {
login: this.state.email,
password: this.state.password
};
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(response => console.log('Succes: ', JSON.stringify(response)))
.catch(error => console.error('Error: ', error));
this.setState({
email: '',
password: ''
});
};
There is nothing wrong in your react/fetch code. You bypass CORS, but probably the api on .pyt1.stg.jmr.pl is understanding it and returning you the response with {"message":"The method is not allowed for the requested URL."}
EDIT: try to run fetch part from NodeJS to verify