JavaScript Require() Function Giving Referenceerror: Require Is Not Defined

Javascript require() function giving ReferenceError: require is not defined

RequireJS is a JavaScript file and module loader. It is optimized for
in-browser use, but it can be used in other JavaScript environments,
like Rhino and Node. Using a modular script loader like RequireJS will
improve the speed and quality of your code.

IE 6+ .......... compatible ✔
Firefox 2+ ..... compatible ✔
Safari 3.2+ .... compatible ✔
Chrome 3+ ...... compatible ✔
Opera 10+ ...... compatible ✔

http://requirejs.org/docs/download.html

Add this to your project: https://requirejs.org/docs/release/2.3.5/minified/require.js

and take a look at this http://requirejs.org/docs/api.html

How to fix Uncaught ReferenceError: require is not defined

You don´t need to import fetch, its part of JS.

var apikey="https://opentdb.com/api.php?amount=10";
fetch(apikey) .then(response => response.json()) .then(json => { // console.log(json); console.log(json.results[0].question); });


Related Topics



Leave a reply



Submit