简体   繁体   English

使用节点获取检索响应查询

[英]Retrieve Response query using node-fetch

One day I was busy using node-fetch to make an HTTP Request , and tried to retrieve the Response Text.有一天,我正忙于使用node-fetch发出HTTP Request ,并试图检索响应文本。 When using Chrome Dev Tools , you can get this information in the Response tab.使用Chrome Dev Tools时,您可以在 Response 选项卡中获取此信息。 Like This:像这样: 在此处输入图像描述

The method of request does not matter.请求的方法无关紧要。

I am trying to access the response text shown in the Response tab, using node-fetch.我正在尝试使用 node-fetch 访问“响应”选项卡中显示的响应文本。 Any idea how or if it is possible to achieve this?知道如何或是否有可能实现这一目标吗? If not, could you provide me with a module that could do this?如果没有,你能给我提供一个可以做到这一点的模块吗? The provided module must be able to do most types of HTTP requests, as well as being lightweight.提供的模块必须能够执行大多数类型的 HTTP 请求,并且是轻量级的。

Thanks in advance.提前致谢。

I've found this piece of software very useful.我发现这个软件非常有用。 I use dev tools a lot, and it definitely has its place, but for diagnosing responses, particularly big responses, I use postman.我经常使用开发工具,它肯定有它的位置,但对于诊断响应,特别是大响应,我使用 postman。

https://www.postman.com/ https://www.postman.com/

I use it for gets, puts, posts etc, it will even give you code samples of your request in quite a few different languages.我将它用于获取、放置、发布等,它甚至会以多种不同的语言为您提供请求的代码示例。

It requires a gmail account.它需要一个 gmail 帐户。 It is somewhat lightweight, i run it server side as well as clientside.它有点轻巧,我在服务器端和客户端运行它。 It has been a lifesaver for diagnosing request headers/ responses.它一直是诊断请求标头/响应的救星。

Here is an example pic.这是一个示例图片。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM