interface BeforeRequestCallbackResult {
data?: any;
header?: any;
method?: Method;
url?: string;
};
import { Http } from "lwu-request";
interface BeforeRequestCallbackResult {
data?: any;
header?: any;
url?: string;
};
/** 请求前拦截 */
const requestInterceptors = ((object: BeforeRequestCallbackResult)=>{
console.log(object)
})
/** 响应拦截 */
const responseInterceptors = () => {
}
export const http = new Http({
baseUrl: {
// 开发环境域名,此处仅为演示
dev: import.meta.env.VITE_API_HOST,
// 生产环境域名,此处仅作为演示
pro: '',
},
// token 携带位置
takeTokenMethod: "header",
before: requestInterceptors,
after: responseInterceptors
});
看了文档,发现1.5版本以上支持请求拦截返回
我现在使用的是1.6.2版本,我的写法如下,不知道怎么样才能读取到 header 。