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 129 天前
```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 129 天前
'Authorization': `${localStorage.getItem('Authorization')}`,
'Authorization': localStorage.getItem('Authorization') || '', |
4
Track13 129 天前 via Android ![]() 不想用!。那就只能提前类型收窄了。
|
![]() |
5
musi 129 天前
as string
|