我是Node Red的新手。
我正在尝试使用授权:http request
为Actility LORAWAN
平台创建一个bearer token without success
。
请求正在运行,我得到了
{
"code" : 401,
"message" : "Permission denied: Authorization header must be set with Bearer token",
"errorId" : null
}
我试图找到一些如何使用授权来执行功能节点的信息:javascript中的bearer,但我找不到任何代码示例?
有人可以帮我一个如何做一个正确的代码并将函数节点与http请求节点连接在一起的例子吗?
亲切的问候
安德烈亚斯豪瑟
这里有一个例子给你,因为你正在发送JSON并期待一个JSON响应
const request = require('request-promise');
request({
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer <YOUR_BEARER_TOKEN_HERE>',
},
json: true,
uri: 'http://localhost:<PORT>/more-url',
method: 'POST',
body: { foo: 'bar' }
})
.then(function (result) {
// do something with result
});