Air-Quality-Web/client_src/js/Helpers/GetFromUrl.mjs

18 lines
447 B
JavaScript
Raw Permalink Normal View History

"use strict";
// From https://gist.github.com/0b2aee73f8d168e36a353901193e7ff5
export default function GetFromUrl(url) {
return new Promise(function(resolve, reject) {
let request = new XMLHttpRequest();
request.addEventListener("load", function() {
if (request.status > 199 && request.status < 300)
resolve(request.response);
else
reject(request.response);
});
request.open("GET", url, true);
request.send(null);
})
}