I am trying to implement promise and fetch in javascript.
I have my class eaHTTP defined in a seperate file call easyHTTP2.js
Hello folks, I keep getting this error each time i run the code below Uncaught ReferenceError: eaHTTP is not define. I already called app2.js and easyHTTP.js in my html file.
//file name: easyHTTP2.js
class eaHTTP {
// Make HTTP Get Request
get(url) {
return new Promise((resolve, reject) => {
fetch(url)
.then(res => res.json())
.then(data => resolve(data))
.catch(err => reject(err));
});
}
}
//file name: app2.js
const htp = new eaHTTP();
// Get Users
htp.get("https://jsonplaceholder.typicode.com/users")
.then(data => console.log(data))
.catch(err => console.log(err));