我正在开发google chrome扩展程序,我想在请求中发送标头,例如:
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: {
ProfileID: "1"
}
});
但是我遇到了错误:
Uncaught TypeError:调用downloads.download(downloads.DownloadOptions选项,可选函数回调)时出错:参数'options'中出错:属性'headers'中出错:类型无效:预期数组,找到对象。
我的问题是如何附加头饰以下载请求
按照docs标头,必须是一个对象数组
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: [
{'ProfileID': '1'}
]
});
你也可以尝试先创建一个标题对象,然后将其添加到阵列这里看看
编辑:尝试与标头对象
chrome.downloads.download({
url: 'http://test/api/file/download',
filename: "file_from_web_api.exe",
headers: new Headers({
'ProfileID': '1'
})
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句