npm xior 0.3.9
v0.3.9

latest releases: 0.6.1, 0.6.0, 0.5.5...
5 months ago
  • feat(core): add try catch to await 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

Don't miss a new xior release

NewReleases is sending notifications on new releases.