I'm trying to load my javascript file in Mongo. However I'm getting the following error:
ReferenceError : XMLHttpRequest is not defined
The Javascript file, seems to function fine and I'm not getting any errors in my browser.
Here's the code related to the request:
var xmlhttp = new XMLHttpRequest();
var url = "https://omgvamp-hearthstone-v1.p.mashape.com/cards";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = JSON.parse(xmlhttp.responseText);
updateCardsCollection(result);
console.log(result);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
This is the line I'm using to load the file:
load("/myPath/database.js")
Note: I'm not using any frameworks yet. I just have the one Javascript file, trying to implement an api and save it to a mongo database.