mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-18 05:53:00 +00:00
18 lines
447 B
JavaScript
18 lines
447 B
JavaScript
|
"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);
|
||
|
})
|
||
|
}
|