I am sending the PUT method (see chrome):
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
console.log("status: ", response.statusText);
return response
} else {
var error = new Error(response.statusText)
error.response = response
throw error
}
}
import fetch from 'isomorphic-fetch'
return dispatch => {
dispatch(requestPosts(data));
return fetch('/trendings', {
method: 'PUT',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
Authorization: Config.token
},
body: JSON.stringify(data),
})
.then(checkStatus)
.then(reponse => {
console.log('request succeeded with JSON response', data);
dispatch(successSent("The output list has been successfully sent!"));
}).catch(err => {
console.log('request failed', err);
dispatch(failSent("Error on sending request: " + err));
});
and the problem is that it returns the OPTIONS method with only status 200.
The problem is that it must follow using the PUT method. In addition, it should return an error because the API endpoint is not ready yet.
Did I miss something?
source
share