Harshit Ruwali
Harshit Ruwali

Reputation: 1088

response.status code is Undefined while using an API

While using an API I am getting undefined rather then the status code like 200 or 404.

app.get('/', function(req, res){

    const url = ''; //The API key

    https.get(url, function(response){

        console.log(response.statuscode);
    });
    res.send('App is running');
});

Upvotes: 0

Views: 1992

Answers (1)

Saurabh Mistry
Saurabh Mistry

Reputation: 13669

it should be : response.statusCode

const req = https.request(options, (response) => {
  console.log('statusCode:', response.statusCode);
});

Upvotes: 1

Related Questions