mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 04:40:39 -07:00
18 lines
443 B
JavaScript
18 lines
443 B
JavaScript
export function get (url) {
|
|
return new Promise((resolve, reject) => {
|
|
const xhr = new XMLHttpRequest()
|
|
xhr.onload = () => {
|
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
resolve(xhr.responseText)
|
|
} else {
|
|
reject(new Error(xhr.statusText))
|
|
}
|
|
}
|
|
xhr.onerror = () => {
|
|
reject(new Error('An error occurred whilst sending the response.'))
|
|
}
|
|
xhr.open('GET', url)
|
|
xhr.send()
|
|
})
|
|
}
|