nostrmarket/static/js/utils.js
Tiago Vasconcelos cc65c91726 Initial skeleton
2023-02-27 18:13:26 +00:00

18 lines
424 B
JavaScript

function loadTemplateAsync(path) {
const result = new Promise(resolve => {
const xhttp = new XMLHttpRequest()
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) resolve(this.responseText)
if (this.status == 404) resolve(`<div>Page not found: ${path}</div>`)
}
}
xhttp.open('GET', path, true)
xhttp.send()
})
return result
}