feat(client): 添加对groupId的处理
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getAuthToken } from '../utils/auth';
|
||||
import {getAuthToken, getGroupId} from '../utils/auth';
|
||||
|
||||
interface RequestOptions extends RequestInit {
|
||||
headers?: Record<string, string>;
|
||||
@@ -13,6 +13,7 @@ export const apiRequest = async <T = any>(
|
||||
options: RequestOptions = {}
|
||||
): Promise<T> => {
|
||||
const authToken = getAuthToken();
|
||||
const groupId = getGroupId();
|
||||
|
||||
const url = endpoint;
|
||||
|
||||
@@ -27,6 +28,11 @@ export const apiRequest = async <T = any>(
|
||||
headers.authorization = `Bearer ${authToken}`;
|
||||
}
|
||||
|
||||
// 如果有groupId,添加groupId头
|
||||
if (groupId) {
|
||||
headers.groupId = groupId;
|
||||
}
|
||||
|
||||
// 发起请求
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user