从节点调用 Url 不起作用

编程入门 行业动态 更新时间:2024-10-28 04:21:33
本文介绍了从节点调用 Url 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用邮递员调用带有标头等的 URL,这工作正常(我能够在邮递员调用中获取令牌),当我尝试从节点使用它时它不起作用,我收到以下错误:

I use postman to call to URL with headers etc which is working fine ( I was able to get the token in postman call ) and when I try to use it from node its not working , i Got the following error :

Error: Error: connect ECONNREFUSED 35.122.111.52:445

我什至从邮递员复制代码并在一些简单的 node.js 应用程序中使用它,但它无法正常工作,知道这里可能有什么问题吗?

I even copy the code from postman and use it in some simple node.js app and its not working , any idea what could be wrong here ?

const server = app.listen(port, () => { "use strict"; console.log("Server listen to port :" + port); var options = { method: 'POST', url: 'app.authentication.orc/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 代理设置.

If you are behind a corporate proxy then set NPM proxy settings as below.

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

更多推荐

从节点调用 Url 不起作用

本文发布于:2023-10-29 12:52:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   不起作用   Url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!