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