|
|
@@ -12,15 +12,20 @@ const taroFetch: typeof fetch = async (input, init) => {
|
|
|
const url = typeof input === 'string' ? input : input.url
|
|
|
const method = init?.method || 'GET'
|
|
|
|
|
|
+ const requestHeaders: Record<string, string> = {};
|
|
|
+
|
|
|
+ if (init?.headers instanceof Headers) {
|
|
|
+ init.headers.forEach((value, key) => {
|
|
|
+ requestHeaders[key] = value;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
// 构建Taro请求选项
|
|
|
const options: Taro.request.Option = {
|
|
|
url,
|
|
|
method: method as any,
|
|
|
data: init?.body,
|
|
|
- header: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- ...Object.fromEntries(new Headers(init?.headers || {}))
|
|
|
- }
|
|
|
+ header: requestHeaders
|
|
|
}
|
|
|
|
|
|
// 添加token
|