Hi,
I was just trying to catch errors in the front-end of my react/redux app when I spotted a really odd behavior.
try {
await api.delete(`roles/${id}`);
dispatch(actions.deleteRole(id));
} catch (error) {
dispatch({
type: types.DELETE_ROLE_ERROR,
payload: {
error,
},
});
}
try {
await api.delete(`roles/${id}`).json();
dispatch(actions.deleteRole(id));
} catch (error) {
dispatch({
type: types.DELETE_ROLE_ERROR,
payload: {
error,
},
});
}
Any idea why this would happen?
Hi @Hinosxz! Thanks for the report and yes this is a bug. We'll definitely get it fixed, but in the mean time, I strongly recommend using one of the Body shortcuts:
await ky().json()
await ky().text()
await ky().formData()
await ky().arrayBuffer()
await ky().blob()
Those should work well, whereas plain await ky() without a Body shortcut is currently missing some features, including retries, HTTP status throws, and afterResponse hooks. It's not intended. PR very much welcome!
Note to all: This has the same underlying cause as #94. See https://github.com/sindresorhus/ky/issues/94#issuecomment-459489020 for a rough idea of what needs to be done.
Most helpful comment
Hi @Hinosxz! Thanks for the report and yes this is a bug. We'll definitely get it fixed, but in the mean time, I strongly recommend using one of the Body shortcuts:
Those should work well, whereas plain
await ky()without a Body shortcut is currently missing some features, including retries, HTTP status throws, andafterResponsehooks. It's not intended. PR very much welcome!Note to all: This has the same underlying cause as #94. See https://github.com/sindresorhus/ky/issues/94#issuecomment-459489020 for a rough idea of what needs to be done.