Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 从节点调用Url无效_Node.js_Rest_Http_Request_Postman - Fatal编程技术网

Node.js 从节点调用Url无效

Node.js 从节点调用Url无效,node.js,rest,http,request,postman,Node.js,Rest,Http,Request,Postman,我使用postman调用带有标题等的URL,这很好(我能够在postman调用中获得令牌),当我尝试从节点使用它时,它不起作用,我得到以下错误: Error: Error: connect ECONNREFUSED 35.122.111.52:445 我甚至从postman那里复制了代码,并在一些简单的node.js应用程序中使用,但它不起作用,你知道这里有什么问题吗 const server = app.listen(port, () => { "use strict";

我使用postman调用带有标题等的URL,这很好(我能够在postman调用中获得令牌),当我尝试从节点使用它时,它不起作用,我得到以下错误:

Error: Error: connect ECONNREFUSED 35.122.111.52:445
我甚至从postman那里复制了代码,并在一些简单的node.js应用程序中使用,但它不起作用,你知道这里有什么问题吗

const server = app.listen(port, () => {
    "use strict";
    console.log("Server listen to port :" + port);

    var options = {
        method: 'POST',
        url: 'https://app.authentication.orc.com/oauth/token',
        headers: {
            grant_type: 'client_credentials',
            authorization: 'Basic c2ItY2xvbmUzZjkwNWRmNmRkYzg0YmXCRjlkZmQ0MDdmMCFiMTc0fGNvbm5lY3Rpdml0eSFiMTM3OkpYQUlyd1BrS2tlQVRDWThDNDFsdkhibGNTbz0=',
            accept: 'application/json;charset=utf-8',
            'content-type': 'application/x-www-form-urlencoded'
        },
        form: {
            grant_type: 'client_credentials',
            token_format: 'opaque&response_type=token'
        }
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);

        console.log(body);
    });
})

如果您在公司代理之后,请按如下所示设置NPM代理设置

npm config set proxy http://"user:P@ssword"@proxy.server:8080 

post man和node js代码是否在同一台机器上运行?@ChandraEskay-是的,从我的mac上…@ChandraEskay-可以选择从postman复制代码如果您运行的请求,我会完全复制它…这很奇怪…您是否支持任何公司代理?如果是,那么设置npm代理设置。@ChandraEskay-是的,我想..我可以试试。请让我知道我应该做什么。。。