Unable to get data from a given url using 'request' module in Nodejs

Hello all- I am new to Node.js. I am facing one problem while doing a http request from an url. Every time it is showing ‘undefined’.

  const request = require('request')
  const url ='https://api.darksky.net/forecast/5a6c29e0d9c879cef11d4d5de29d7d78/37.8267,-122.4233'
  request({ url:url }, (error,response) => {

Node and npm version I am using –
C:\Users\lenovo>node -v

C:\Users\lenovo>npm -v
and the dependency list attached belowdependency

Do you have this project on GitHub? If so, please provide a link to it, so we can take a look at all the code.

Thank you.

Hi Randell - Sorry, this code is not there on GitHub. Do you need any more info I can assist you with?

My recommendation is to put your code up on GitHub so we can clone it and test it locally.

Umm… does the second line above have an equals? const url 'https://...' is likely throwing up an error.

1 Like

Hi snowmonkey - That was an typo. ignore it and proceed.

Hi, I don’t think you have any problem with your code. I just ran your code and I am getting valid response.