Import 'request' package error

Hi,

I am new to LightningJS. I’m trying to get data from other websites, but there is an error importing the request package.

import request from ‘request’
export function req (url){
request.get(url, ( err, res ) => {
console.log(res)
})
}

Hi Salhl,

are you using this module? request - npm. It is deprecated and unnecessary for Lightning.

In Lightning, try to use Fetch: Using the Fetch API - Web APIs | MDN

If you’ve not come across the Fetch API before, drop me a note and I can try to assist.

1 Like

Hi JacobReilly-Cooper,

Thank you for your help. I tried the fetch API and the problem is solved.

1 Like

Brilliant, Salhl.

Really glad it worked!