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!

I understand that you are encountering an error related to the ‘request’ package. The ‘request’ package is a popular HTTP client library used in Node.js for making HTTP requests to external resources.

If you are facing an issue with importing the ‘request’ package, there are a few things you can check and try to resolve the problem:

  1. Package Installation: Ensure that you have installed the ‘request’ package in your Node.js project. Open your terminal or command prompt and navigate to your project directory. Then run the following command to install the ‘request’ package:

For more information check this: https://yardgearsguide.com/how-to-test-small-engine-ignition-coil-without-multimeter/