javascript - curl http请求到node-red
问题描述
我对 node-red 非常陌生,对向 node-red 发送 http 请求一无所知。我一直在尝试这种方法来向 node-red 发送请求,但它给了我状态码 0。
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://my.node.com:port/endpoint", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
data: "data"
}));
console.log(xhr.status);
我的上级建议我使用 curl 命令——我不知道该怎么做。由于时间有限,我不习惯使用 curl,也没有时间深入探索。我尝试使用此方法,但返回错误msg undefined
msg.payload = "data to post";
msg.headers = {};
msg.headers['content-type'] = 'application/json';
return msg;
如何向 node-red 发送 http 请求?
解决方案
推荐阅读
- java - 在我尝试访问应用程序时在tomcat 8中成功部署角度js项目构建后,它没有显示空白页面
- javascript - HTML Canvas 的文本未显示在屏幕上
- angular - @azure/msal-angular 注销重定向到应用程序,但应用程序不显示
- ios - 有没有办法在 Swift 中反转动画?
- c - 如何通过串行打印浮点数?
- sql-server - T-SQL:创建存储过程以更新表中的列,其中表和字段作为参数
- angular - 如何检测用户已到达虚拟滚动角度 7 中的列表末尾?
- python - 请求模块是否不从谷歌获取完整数据(网络抓取)
- angular - 无法访问检查变量;它在 html 中显示 [object Object](角度 7)
- python - 用python中的反射填充有效地填充掩码数组值