2022-06-15 21:50:04 +08:00

12 lines
357 B
TypeScript

export function GET(url: string) {
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
resolve && resolve(xhr.responseText);
}
};
xhr.open("GET", url, true);
xhr.send();
})
}