如何将负载添加到 coap 请求 node-coap
How to add payload to coap request node-coap
我正在使用 node-coap (https://github.com/mcollina/node-coap) 发送 Coap 数据包,现在我正在尝试 post 或将请求与负载一起发送,但我不明白如何向请求添加有效负载。我必须使用什么方法或 属性 来插入负载?
他们的回购中有一个例子:
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));
我正在使用 node-coap (https://github.com/mcollina/node-coap) 发送 Coap 数据包,现在我正在尝试 post 或将请求与负载一起发送,但我不明白如何向请求添加有效负载。我必须使用什么方法或 属性 来插入负载?
他们的回购中有一个例子:
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));