I'm developing google chrome extension, I want to send headers in the request like:
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: {
ProfileID: "1"
}
});
But I'm getting error:
Uncaught TypeError: Error in invocation of downloads.download(downloads.DownloadOptions options, optional function callback): Error at parameter 'options': Error at property 'headers': Invalid type: expected array, found object.
My question is how to append headres to download request
As per the docs headers need to be a Array of objects
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: [
{'ProfileID': '1'}
]
});
you can also try to create a header object first and then add it to the array look here
EDIT: try with header object
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: new Headers({
'ProfileID': '1'
})
});