小编cha*_*ala的帖子

错误:使用 request-promise 模块在 Node JS 中挂断套接字

我在发送请求时收到套接字挂断错误消息。根据观察请求正在处理,但在发送响应时,我收到以下响应:

 {
   "success":false,
   "error":{
     "name":"RequestError","message":"Error: socket hang up","cause":{"code":"ECONNRESET"},
     "error":{"code":"ECONNRESET"},
     "options":{"uri":"request url","simple":true,"resolveWithFullResponse":false,"transform2xxOnly":false}
   }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用以下代码:

var options = {
  uri: 'request url',
};
request(options).then(function(data) {
    res.json({
      success: true,
      data: data
    });     
 })
 .catch(function (err) {
    res.json({
      success: false,
      error: err,
    });
});
Run Code Online (Sandbox Code Playgroud)

request node.js

7
推荐指数
0
解决办法
7943
查看次数

标签 统计

node.js ×1

request ×1