报错信息:
Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': The provided value is not of type '(record<ByteString, ByteString> or sequence<sequence<ByteString>>)'.
拦截器部分代码
const authHeaderInterceptor = (url: string, options: any) => {
if (history.location.pathname == loginPath || history.location.pathname == registerPath) {
return {
url: `${url}`,
options: {...options,},
};
}else {
return {
url: `${url}`,
options: {...options, interceptors: true, headers: localStorage.getItem('token')},
};
}
};
export const request: RequestConfig = {
// 新增自动添加AccessToken的请求前拦截器
requestInterceptors: [authHeaderInterceptor],
};
未能在“窗口”上执行“fetch”:未能从“RequestInit”读取“headers”属性:提供的值不是类型(record<ByteString,ByteString>或sequence<sequence)