【发布时间】:2019-07-15 08:36:11
【问题描述】:
当我使用邮递员调用 API 时,它给了我成功响应,但是我尝试使用 Node js 应用程序的代码相同,然后它给了我类似的错误。那么我是否在服务器端犯了任何错误或错误?我还尝试了邮递员生成的示例代码。但它也给出了一个错误。对于请求,我使用了 request-promise 和 request 两个 npm 包
<html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white"> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html>
示例代码:
var options = {
method: 'PUT',
url: 'http://IPAdd/app/v1/device/mac/zz',
headers:
{
'content-type': 'application/json',
authorization: 'Token '+ token },
body:
{ //body JSON},
json: true,"rejectUnauthorized": false
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
【问题讨论】:
标签: node.js api request postman