Buscar: rejeitar a promessa e detectar o erro se o status não estiver bom?
Aqui está o que eu vou:
import 'whatwg-fetch';
function fetchVehicle(id) {
return dispatch => {
return dispatch({
type: 'FETCH_VEHICLE',
payload: fetch(`http://swapi.co/api/vehicles/${id}/`)
.then(status)
.then(res => res.json())
.catch(error => {
throw(error);
})
});
};
}
function status(res) {
if (!res.ok) {
return Promise.reject()
}
return res;
}
EDIT: A promessa não é rejeitada, é o que estou tentando descobrir.
Estou usando issobuscar polyfill em Redux comredux-promessa-middleware.