promises
This commit is contained in:
parent
a68022a8d6
commit
04b2fcfba2
17 changed files with 304 additions and 137 deletions
13
8-async/02-promise-basics/head.html
Normal file
13
8-async/02-promise-basics/head.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<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);
|
||||
});
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue