Node + Pokeapi "Error: connect ECONNREFUSED 127.0.0.1:443"

0

I'm new to the Nodejs world, I wonder why I can not test the most basic document algorithm link

My code looks like this:

var Pokedex = require('pokedex-promise-v2');
var options = {
  protocol: 'https',
  hostName: 'localhost:443',
  versionPath: '/api/v2/',
  cacheLimit: 100 * 1000, // 100s
  tiemout: 5 * 1000 // 5s
}
var P = new Pokedex(options);
 P.getBerryByName('cheri')
    .then(function(response) {
      console.log(response);
    })
    .catch(function(error) {
      console.log('There was an ERROR: ', error);
    });
    
asked by anonymous 26.04.2017 / 04:08

2 answers

0

This error usually occurs when the port used is already in use. Run the command below to verify who is using the port.

$ netstat -lant | grep ":443" 
    
26.04.2017 / 21:39
0

From what I've seen, your json options is in trouble. try:

var options = { protocol: 'https', hostName: 'pokeapi.co', versionPath: '/api/v2/' }

    
29.04.2017 / 02:54