mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 09:27:50 +00:00
21 lines
508 B
TypeScript
21 lines
508 B
TypeScript
import { getAuthToken, setAuthToken } from '@app/reactQuery';
|
|
|
|
// depreciated: go for apiRequest module in config/api
|
|
export default class SecurityClient {
|
|
static setToken(tokenStr: string) {
|
|
setAuthToken(tokenStr);
|
|
}
|
|
|
|
static async fetchCall(resource: RequestInfo, options?: RequestInit | undefined) {
|
|
const req = new Request(resource, options);
|
|
|
|
const token = getAuthToken();
|
|
|
|
if (token) {
|
|
req.headers.set('Authorization', `Bearer ${token}`);
|
|
}
|
|
|
|
return fetch(req);
|
|
}
|
|
}
|