12 lines
357 B
TypeScript
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();
|
|
})
|
|
} |