[英]How to add payload to coap request node-coap
I'm using node-coap ( https://github.com/mcollina/node-coap ) to send Coap packets, now I'm trying to do post or put requests with payload, but I haven't understand how to add payload to request. 我正在使用node-coap( https://github.com/mcollina/node-coap )发送Coap数据包,现在我正在尝试使用有效负载来发布或放置请求,但是我不知道如何添加有效载荷要求。 What method or property I have to use to insert the payload?
我必须使用什么方法或属性来插入有效负载?
There is an example there in their repo: 他们的仓库中有一个例子:
https://github.com/mcollina/node-coap/blob/master/examples/req_with_payload.js https://github.com/mcollina/node-coap/blob/master/examples/req_with_payload.js
var req = coap.request('coap://localhost/Matteo')
var payload = {
title: 'this is a test payload',
body: 'containing nothing useful'
}
req.write(JSON.stringify(payload));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.