1555
This commit is contained in:
1 parent
ad1f7618ff
commit
38e203512d
2 files changed
+22
-6
No files matched your search
@@ -0,0 +1,9 @@
|
||||
// 带认证的 fetch 封装
|
||||
export async function authFetch(url: string, options: RequestInit = {}): Promise<Response> {
|
||||
const token = localStorage.getItem("wauth_token");
|
||||
const headers = new Headers(options.headers);
|
||||
if (token) {
|
||||
headers.set("X-Auth-User", token);
|
||||
}
|
||||
return fetch(url, { ...options, headers });
|
||||
}
|
||||
Reference in new issue
Block a user