node.js - 在 NodeJS 中设置不记名令牌
问题描述
我有一个使用 NodeJS 的 Web 后端。我想使用链接从另一台服务器检索数据,例如https://evoDMSTDev/api/api_event_all.php
,并且必须使用不记名令牌71D55F6907509
来访问它。那么,我必须在哪里设置令牌,以便我可以检索该数据并将其显示在我的 Web 后端?
感谢您的帮助 :)
解决方案
我在节点 js 中创建这样的,然后只需调用obj
你的.ejs
request({
uri : 'https://evoDMSTDev/api/api_events_all.php',
auth: {
'bearer': '71D55F99570209'
},
rejectUnauthorized: false,//add when working with https sites
requestCert: false,//add when working with https sites
agent: false,//add when working with https sites
}, function(error, response, body) {
if (error) {
console.log(error);
} else {
obj = JSON.parse(body);
}
}
推荐阅读
- r - 在随机选择的行中更改 R 数据框中的值
- php - 从日期数组中提取年份
- c++ - c++ std::thread join() 在线程超出范围后
- web - 如何将 Skaffold 项目连接到本地网络但不同计算机上的集群
- c - 用于宏定义的 C 中带有省略号的 sprintf 会导致编译错误
- java - 如何计算字符串中的括号?
- django - 检查以检查 Django 中是否存在数据库表?
- kdb - kdb:解析“x[y]”的类型是什么?
- javascript - Javascript点击总是从具有相似类的多个项目中获取第一个项目
- elasticsearch - 使用额外的引号形成弹性搜索查询