clear declarations
This commit is contained in:
parent
9b03ee79bd
commit
49fbecca83
2 changed files with 0 additions and 31 deletions
|
@ -10,25 +10,6 @@ function loadScript(src) {
|
|||
document.head.append(script);
|
||||
});
|
||||
}
|
||||
|
||||
class HttpError extends Error {
|
||||
constructor(response) {
|
||||
super(`${response.status} for ${response.url}`);
|
||||
this.name = 'HttpError';
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
|
||||
function loadJson(url) {
|
||||
return fetch(url)
|
||||
.then(response => {
|
||||
if (response.status == 200) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new HttpError(response);
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
<script>
|
||||
function loadScript(src) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let script = document.createElement('script');
|
||||
script.src = src;
|
||||
|
||||
script.onload = () => resolve(script);
|
||||
script.onerror = () => reject(new Error("Script load error: " + src));
|
||||
|
||||
document.head.append(script);
|
||||
});
|
||||
}
|
||||
|
||||
class HttpError extends Error {
|
||||
constructor(response) {
|
||||
super(`${response.status} for ${response.url}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue