2

I'm a beginner in node.js. I would like to connect with API for training. I'm behind the company proxy. I have an api-key: http://numbersapi.com/2000/math?json and I want to connect via node-fetch, but I get an error in console:

Error:  { FetchError: request to http://numbersapi.com/2000/math failed, reason: connect ECONNREFUSED 107.170.248.47:80
    at ClientRequest.<anonymous> (C:\user\training\Node.js\number_API\node_modules\node-fetch\lib\index.js:1455:11)
    at ClientRequest.emit (events.js:193:13)
    at Socket.socketErrorListener (_http_client.js:397:9)
    at Socket.emit (events.js:193:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)
  message:
   'request to http://numbersapi.com/2000/math failed, reason: connect ECONNREFUSED 107.170.248.47:80',
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED' }

I have set properties in .npmrc:

proxy=http://xxx.xxx.com:8080
https-proxy=http://xxx.xxx.com:8080
registry=https://registry.npmjs.org
Vuzii
  • 75
  • 8
  • 1
    Can you access ```http://numbersapi.com/2000/math``` on your browser or ```postman```? – Tien Duong Jul 31 '19 at 07:46
  • Yes in browser,I don't use postman, for now. API-key is : http://numbersapi.com/2000/math?json i made mistake – Vuzii Jul 31 '19 at 07:59

1 Answers1

0

To the best of my knowledge node-fetch does does not honor the environment variables or anything defined in .npmrc. You need to explicitly define the proxy.

Chris H
  • 501
  • 1
  • 4
  • 15