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-01-23 22:20:38 +08:00
```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-01-23 22:38:40 +08:00
'Authorization': `${localStorage.getItem('Authorization')}`,
'Authorization': localStorage.getItem('Authorization') || '', |
4
Track13 2023-01-24 09:05:30 +08:00 via Android 1
不想用!。那就只能提前类型收窄了。
|
5
musi 2023-01-24 11:50:31 +08:00
as string
|