我使用警报来使用 github v3 api 获取 github 通知,并注意到 fetch api 被及时调用,但没有得到最新结果,不知道可能是什么问题?
try{
const count = await getNotifications(searchQueries);
await chrome.storage.local.set({[dbName]: count})
chrome.storage.local.get(dbName, showNotification);
}catch(e) {
console.log(e)
}
...
async function getNotifications(repo) {
const headers = {
'Authorization': `Bearer ${access_token}`,
'Content-Type': 'application/json',
}
let response = await fetch(`https://api.github.com/notifications`, {headers});
const notifications = await response.json();
// alert(notifications.length)
return notifications.length
}