我试图在Typescript中使用Request包,方法定义为: -
export function request(options?: Options, callback?: (error: any, response: any, body: any) => void): Request;
我在尝试匹配选项中的标题时遇到问题。选项和标题定义为: -
export interface Options {
url?: string;
headers?: Headers;
...
...
export interface Headers {
[key: string]: any;
}
我的选项如下: -
var requestOptions = {
url: 'https://www.wigglewoowoo.com',
method: 'POST',
headers: {
'Connection': 'close'
},
body: returnBody,
strictSSL: true,
rejectUnauthorized: false,
requestCert: true,
agent: false
};
我得到"不能分配给选项" 类型的参数,除非我排除标题。我看不出它有什么问题?