- feat(core): add
try catch
toawait fetch(...)
Now you can capture the request error in response intecetptors, and the error will be TypeError
:
import xior, { merge } from 'xior';
const http = xior.create({
// ...options
});
http.inteceptors.response.use(
(result) => {
return result;
},
async (error) => {
if (error instanceof TypeError) {
console.log(`Request error:`, error);
}
if (error?.response?.status === 401) {
localStorage.removeItem('REQUEST_TOKEN');
}
}
);
Full Changelog: v0.3.8...v0.3.9