获取对话信息
This commit is contained in:
11
web/apps/web-antd/src/utils/fetch-with-auth.ts
Normal file
11
web/apps/web-antd/src/utils/fetch-with-auth.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { formatToken } from '#/utils/auth';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
export function fetchWithAuth(input: RequestInfo, init: RequestInit = {}) {
|
||||
const accessStore = useAccessStore();
|
||||
const token = accessStore.accessToken;
|
||||
const headers = new Headers(init.headers || {});
|
||||
headers.append('Content-Type', 'application/json');
|
||||
headers.append('Authorization', formatToken(token) as string);
|
||||
return fetch(input, { ...init, headers });
|
||||
}
|
||||
Reference in New Issue
Block a user