节点请求添加标头

用户2875404

我想pipe()要求

request
 .get(url)
 .pipe(process.stdout)

工作并打印到控制台。现在,如果我尝试添加标题

request
 .get(url)
 .setHeader(headers)
 .pipe(process.stdout)

我明白了Property 'pipe' does not exist on type 'void'如果我反过来做,我会得到Property 'setHeader' does not exist on type 'WriteStream...

这些“内联参数”的组合是有限的还是我做错了什么?

穆萨

您可以将对象传递给带有标题的 get 方法

request
 .get({uri: url, headers: headers})
 .pipe(process.stdout)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章