gpt4 book ai didi

node.js - 如何在nodejs中调试request.post

转载 作者:太空宇宙 更新时间:2023-11-04 00:24:23 25 4
gpt4 key购买 nike

有人可以给我调试下面代码片段的想法吗?

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)
}
}
);
}

我想检查一下它是否有效。以及如何使用 postman api 进行测试

非常感谢您的帮助

最佳答案

在 postman 的 URL 部分中添加 52.7.0.131/SendInfo/XC1K1AZ9 此 URL,方法为 POST,然后导航到正文标签,然后选择原始单选按钮。然后在同一行中,您将看到 [Text] 组合框,单击该组合框并选择 JSON(application/json)。然后仅粘贴下面的 { reportType: 'customer', comment: customerDetails.cust_id, imageUrl: customerDetails.url1 } 这部分 json,然后单击“发送”按钮。

关于node.js - 如何在nodejs中调试request.post,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43365715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com