Changelog
v0.4.0 2024/04/24
Breaking Change
This version is about Axios compatible issue in some cases. Fixing https://github.com/suhaotian/xior/issues/12 and https://github.com/suhaotian/xior/issues/15.
responseType: 'blob' | 'arrarybuffer'
then the resposne.data
is Blob
and ArrayBuffer
, no need response.blob()
or response.arraybuffer()
anymore.Changelog
v0.3.13 2024/04/21
cacheTime
to cache pluginChangelog
v0.3.12 2024/04/13
cacheTime
is undefined when useCacheFirst: true
Changelog
v0.3.10 2024/04/11
error-retry
plugin's retryInterval
add config
and error
to parametersChangelog
v0.3.9 2024/04/9
try catch
to await fetch(...)
Now you can capture the request error in response interceptors, and the error will be TypeError
:
import xior, { merge } from 'xior';
const http = xior.create({
// ...options
});
http.interceptors.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');
}
}
);
Changelog
v0.3.8 2024/04/8
enable*
logicNow you can return undefined
in enable*
method:
import xior from 'xior';
import errorRetryPlugin from 'xior/plugins/error-retry';
const http = xior.create();
http.plugins.use(
errorRetryPlugin({
enableRetry(config, error) {
if (error.response?.status === 401) {
return false;
}
// no return here, and will reuse the default `enableRetry` logic
},
})
);
Changelog
v0.3.7 2024/04/7
useCacheFirst
to error cache pluginIf
useCacheFirst: true
and there's a cache, it will return the cached response first, then run fetching in the background. This is useful when the response takes a long time, and the data is unnecessary in real-time.