-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
Hi,
I was wondering if the Fetch api could unintentionally releasing the Zalgo
if(action.type === API_REQUEST) {
const { method, url, onSuccess, onError } = action.meta;
fetch(url, { method }).then(response => response.json())
.then((data) => dispatch({ type: onSuccess, payload: data }))
.catch(error => dispatch({ type: onError, payload: error }))
}
return next(action)
What do you think of changing it to:
if(action.type === API_REQUEST) {
const { method, url, onSuccess, onError } = action.meta;
return fetch(url, { method }).then(response => response.json())
.then((data) => {
dispatch({ type: onSuccess, payload: data });
return next(action);
});
.catch(error => dispatch({ type: onError, payload: error }))
}
return Promise.resolve(next(action));
At the end next(action) is always executed async but the flow will continue normally.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels