Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f4efb11

Browse files
committed
use promises
1 parent 0ad152a commit f4efb11

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/index.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Promise.all([
2929
// dang huge (> 40Mb). In the meantime the textarea that is holding the place
3030
// of the actual functional one is just going to display "Loading...".
3131
import("./createRuby").then(({ default: createRuby }) => createRuby())
32-
]).then(async ([editor, mermaid, ruby]) => {
32+
]).then(([editor, mermaid, ruby]) => {
3333
// First, grab a reference to the output element so that we can update it.
3434
// Then, set it initially to the output represented by the source.
3535
const output = document.getElementById("output");
@@ -113,13 +113,10 @@ Promise.all([
113113
// fetch code from URL
114114
const params = new URLSearchParams(document.location.search)
115115
const sourceURL = params.get('source')
116-
try {
117-
const response = await fetch(new URL(sourceURL))
118-
if (response.status === 200) {
119-
const data = await response.text()
120-
editor.setValue(data)
121-
}
122-
} catch (error) {
123-
console.error(error)
116+
if (sourceURL) {
117+
fetch(new URL(sourceURL))
118+
.then(response => response.text())
119+
.then(data => editor.setValue(data))
120+
.catch(error => console.error(error))
124121
}
125122
});

0 commit comments

Comments
 (0)