-
peter_rabbit authoredpeter_rabbit authored
fetch.js 521 B
"use strict";
function fetchjson(url) {
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
.then(r => r.json())
.then(r => resolve(r))
.catch(e => reject(e));
});
}
function fetchtext(url) {
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
.then(r => r.text())
.then(r => resolve(r))
.catch(e => reject(e));
});
}
module.exports = {
fetchjson,
fetchtext,
};