1.但是不知道 用async 请求怎么获取这个header ,真的是百思不得其解
uni.request({
url: url, //仅为示例,并非真实接口地址。
data: params,
method:'POST',
header: {
'custom-header': 'hello' //自定义请求头信息
},
success: (res) => {
console.log(res.header['Set-Cookie']);
console.log(JSON.stringify(res))
this.text = 'request success';
}
});
// 请求拦截,配置Token等参数 ,在登录处设置好token
Vue.prototype.$u.http.interceptor.request = (config) => {
const Cookie = uni.getStorageSync('token');
config.header.Cookie = Cookie;
return config;
}