我正在尝试从API中获取数据点。我使用了身份验证凭据和令牌来访问,并且收到带有200码的状态消息“确定”。我知道我正在访问,但无法查看这些点,也无法在终端或DOM的控制台中流式传输任何数据。
1)我用Postman进行了测试,我可以在终端中获取所有数据
$this->form_validation->set_rules('field_name', 'Field description', 'required|is_unique[tablename.fieldname]');
运行 method: 'GET',
url: 'https://www.url.io/rest/method/url-api/getDeviceData',
qs: { happy_token: 'eyJ0eXAiOiJKiOiJIUzI1NiJ9.ImlkfDM4ZDQ4OWM1LWI3YzUtNDE1Ni05ZWJlLWJmYzViMmJkODk1OXx0eXBlfHRpbWVzdGFtcHxpc0VuY3J5cHRlZHxvcmlnaW58MTAtMC0yOC0xODFfNTcwMDB8cG9saWN5fDHRsfGluYWN0aXZpdHlfdGhyZXNob2xkfDF8aXNUb2tlbnx1c2VybmFtZXxtb2hhbWVkLmZheWVkQHBkaWNvcnAuY29tfEd8NHwtMnw1fDZ8N3wkOHwkOXxIfEF8LTNdfEJ8JDl8SXxBfC0zXV18Q3wtMXxEfEVdIg.PaQdlILLK9lWN8zjmthTgWY_r77oBw' },
headers:
{
'cache-control': 'no-cache',
Connection: 'keep-alive',
'accept-encoding': 'gzip, deflate',
cookie: 'AWSALB=A+sdBzwAGrQmRer2y4ENHQgCc8TdDKiLHkM68CJMVKNhpVEBkiW53AhWSRKmzwk9scGKbSHeWtWL9YzuBayGFyWdkmkd5fkFSp2FYxbraW75UOoi8YtY',
Host: 'www.url.io',
'Postman-Token': '08e1668d-1f49-4451-a47e-61c9bae9df08,84944b9f-17eb-4520-88b2-344a7c46bdca',
'Cache-Control': 'no-cache',
Accept: '*/*',
'User-Agent': 'PostmanRuntime/7.13.0',
Authorization: 'Basic bW9oYW1lZC5ZEBwZGljb3JwLmNpAbWZheWVkMjk5OA=='
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
之后,我得到一个漂亮的JSON响应:
npm start
这就是我要去的地方!
但是,编写我的代码时,如下:
"message": "Call successful",
"data": {
"device_id": {
"data": [
{
"parameters": {
"node_id": "1",
"ip_address": "172.00.00.00",
"tcp_id": "1"
},
"type": "P",
"mapping": "P",
"name": "P name",
"deviceName": "P name",
"path": "/profileView/devices/p name",
"deviceType": "P",
.
.
.
(etc)
这是我在终端中得到的:
此外,我在控制台日志中看不到任何内容: Browser View 我觉得我正在发送正确的请求,但是我无法发布数据。谁能提供任何见解?谢谢!