Google chrome extension 下载带有标题的文件请求chrome扩展名

Google chrome extension 下载带有标题的文件请求chrome扩展名,google-chrome-extension,download,Google Chrome Extension,Download,我正在开发google chrome扩展,我想在请求中发送标题,如: chrome.downloads.download({ url: 'http://test/api/file/download', filename: "file_from_web_api.exe", headers: { ProfileID: "1" } }); 但我得到了一个错误: 未捕获类型错误:调用downloads.download(downloads.downloa

我正在开发google chrome扩展,我想在请求中发送标题,如:

chrome.downloads.download({
    url: 'http://test/api/file/download',
    filename: "file_from_web_api.exe",
    headers: {
        ProfileID: "1"
    }
});
但我得到了一个错误:

未捕获类型错误:调用downloads.download(downloads.downloadpoptions选项,可选函数回调)时出错:参数“选项”处出错:属性“标头”处出错:无效类型:应为数组,找到对象

我的问题是,如何根据头需要是一个对象数组,将头附加到下载请求中

chrome.downloads.download({
    url: 'http://test/api/file/download',
    filename: "file_from_web_api.exe",
    headers: [
        {'ProfileID': '1'}
    ]
});
您还可以尝试先创建一个header对象,然后将其添加到数组中

编辑:尝试使用标题对象

chrome.downloads.download({
    url: 'http://test/api/file/download',
    filename: "file_from_web_api.exe",
    headers: new Headers({
        'ProfileID': '1'
    })
});

谢谢,现在我遇到了另一个错误:
Uncaught TypeError:downloads.download调用错误(downloads.downloadpoptions选项,可选函数回调):参数“options”错误:属性“headers”错误:索引0错误:意外属性:“ProfileID”。
oh my bad我想应该是{ProfileID':“1}扩展文档当然不好,但它仍然明确指出对象应该有键
name
value
,例如
{name:'ProfileID',value:'1'}
噢,酷,Codey让我们知道它是否有效,以便我们可以更新答案。(文档中没有示例)