本文介绍了从节点调用 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 不起作用
发布评论