mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
25 lines
529 B
TypeScript
25 lines
529 B
TypeScript
import { configureRefreshFetch, fetchJSON } from 'refresh-fetch';
|
|
|
|
const fetchJSONWithToken = (url: string, options?: RequestInit): Promise<{ body: {}; response: Response }> => {
|
|
return fetchJSON(url, options);
|
|
};
|
|
|
|
const refreshToken = (): Promise<void> => {
|
|
return fetchJSON<{
|
|
refreshToken: string;
|
|
}>(
|
|
'url',
|
|
{
|
|
method: "GET"
|
|
},
|
|
).then(() => {
|
|
return;
|
|
});
|
|
};
|
|
|
|
const fetch = configureRefreshFetch({
|
|
fetch: fetchJSONWithToken,
|
|
shouldRefreshToken: (): boolean => true,
|
|
refreshToken,
|
|
});
|