Why I can't get `browser.downloads` in background.js
jacktang opened this issue · comments
Jack Tang commented
In background/main.ts
I tried to save some filed on some specified message. And the code snippet
onMessage('save-me', async () => {
console.log("downloads?", browser.downloads);
const blob = new Blob(["array of", ' parts of ', "text file"], {type: "text/plain"});
const url = URL.createObjectURL(blob);
try {
await browser.downloads.download({
url,
filename: 'test.txt',
})
} catch (error) {
console.log('saved failed', error);
}
})
browser.downloads
always undefined
. Do you know why?
Jack Tang commented
i got it. I missed opening permission.