2

I am just trying to print some data to the console to make sure my node.js app is receiving data to manipulate. I have formatted my code like so.

const rP = require('request-promise');

rP({
    'method'  : 'GET',
    'uri'     : 'https://football-data.org/v2/competitions/PL/matches',
    'json'    : true,
    'headers' : {
        'X-Auth-Token' : 'api-key'
    },
    'insecure': true
})
.then(console.log, console.log);

The error I get back is

RequestError: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: football-data.org. is not in the cert's altnames: DNS:api.football-data.org

I have tried adding " 'insecure' : true " to the parameters to no effect as suggested in another answer. Also that same answer suggested using 'self-signed certificates' and pointed me here. I am new to node.js so am unfamiliar with making api calls from the server and do not understand the information in the link about self-signed certificates.

Any suggestions would be very much appreciated.

Apologies if this question is incorrectly formatted, it's my first.

Manny
  • 23
  • 3

1 Answers1

2

add rejectUnauthorized: false to object you pass to request. Albeit, this is not good idea from security point of view,

rasjani
  • 7,372
  • 4
  • 22
  • 35