节点红,带授权的Http请求:承载

问题描述 投票:0回答:1

我是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请求节点连接在一起的例子吗?

亲切的问候

安德烈亚斯豪瑟

javascript http node-red
1个回答
0
投票

这里有一个例子给你,因为你正在发送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
});
© www.soinside.com 2019 - 2024. All rights reserved.