const coap = require('coap');
// define connection options
hostname: "coap.akenza.io",
query: "secret={secret}&deviceId={deviceId}",
"Content-Format": "application/json",
// create the request object
const req = coap.request(options);
temperature: Math.random() * 100,
req.write(JSON.stringify(payload));
// handle success response
req.on('response', function (res) {
res.pipe(process.stdout);
req.on('error', function (err) {
console.log("error while sending coap request", err);