2017-04-12 67 views
0

可能会让我想到调试下面的代码片段。如何调试nodejs中的request.post

var request = require('request'); 

function sendINFO() { 
    var jsonString = { 
     reportType: 'customer', 
     comment: customerDetails.cust_id, 
     imageUrl: customerDetails.url1 
    } 
    console.log('json string', jsonString) 
    request.post(
     'http://52.7.0.131/SendInfo/XC1K1AZ9', { 
      json: jsonString 
     }, 
     function(error, response, body) { 
      console.log('response after adding report', response, 'error', error) 
      if (!error && response.statusCode == 200) { 
       console.log(body) 
      } 
     } 
    ); 
} 

我想检查它是否正常工作。以及如何与邮差API测试这个

非常感谢您的帮助

+1

在邮递员打http://52.7.0.131/SendInfo/XC1K1AZ9这个URL与方法作为POST和发送jsonString数据原始的身体和格式为JSON – AJS

+0

我不明白你在说什么。 我只是做了这样的52.7.0.131/AddReport/FC5E1BF6' ,{JSON:jsonString} 后来我选择了生,还有我给像下面 VAR jsonString = { REPORTTYPE: '顾客', 评论:为CustomerDetails。 cust_id, imageUrl:customerDetails.url1 } – kimi

+0

经过我的回答,低于 – AJS

回答

1

在URL部分邮递员添加52.7.0.131/SendInfo/XC1K1AZ9这个网址与方法POST然后导航到body标签,然后选择生收音机按钮。然后在同一行中,您将看到[Text]组合框单击它并选择JSON(application/json)。然后只粘贴{ reportType: 'customer', comment: customerDetails.cust_id, imageUrl: customerDetails.url1 }这部分json下面,然后点击发送按钮。

+0

感谢的人,现在明白了。我将如何测试,而不使用邮递员 – kimi

+0

然后也接受我的回答 – AJS

+0

你能告诉我如何调试整个功能。我只是单独检查一下api。它的工作正常。但作为它的功能它不工作......如何调试这个“函数sendINFO(){} – kimi