fetch(`${url.baseUrl}${url.user.auth}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
//'Authorization': localStorage.getItem('Authorization'),
},
}).then((response) => {
if (response.status == 200) {
auth = true;
}
});
localStorage.getItem('Authorization')type 是 string|null 和headers要求的参数类型不匹配
1
lisongeee 2023 年 1 月 23 日
```ts
fetch(`${url.baseUrl}${url.user.auth}`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': localStorage.getItem('Authorization')!, }, }).then((response) => { if (response.status == 200) { auth = true; } }); ``` |
2
icebay 2023 年 1 月 23 日
'Authorization': `${localStorage.getItem('Authorization')}`,
'Authorization': localStorage.getItem('Authorization') || '', |
4
bgm004 2023 年 1 月 24 日 via Android 不想用!。那就只能提前类型收窄了。
|
5
musi 2023 年 1 月 24 日
as string
|