0

I am using script type module to run api in client side using request but getting error as require is not defined? How can I make it run on browser(client side) with script type module script below is the api I am using:

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://manga-scraper-for-mangakakalot-website.p.rapidapi.com/search',
  qs: {keyword: 'memori', page: '1'},
  headers: {
    'X-RapidAPI-Host': 'manga-scraper-for-mangakakalot-website.p.rapidapi.com',
    'X-RapidAPI-Key': 'xxxxx',
    useQueryString: true
  }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});
  • 1
    You should check this thread which actually solves your case https://stackoverflow.com/questions/19059580/client-on-node-js-uncaught-referenceerror-require-is-not-defined – Oris Sin Apr 06 '22 at 09:17
  • I did check but I didn't get it – Gaito Uchiha Apr 06 '22 at 09:47
  • 1
    Check this one also that explains how you can inject the RequireJS library for Javascript files and modules loader. https://stackoverflow.com/questions/23603514/javascript-require-function-giving-referenceerror-require-is-not-defined – Oris Sin Apr 06 '22 at 09:51

0 Answers0