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

Commit dfeaeb3

Browse files
authored
Pull code from remote source
1 parent 90bba8d commit dfeaeb3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,17 @@ Promise.all([
109109
});
110110

111111
toggles.querySelector("select").removeAttribute("disabled");
112+
113+
// fetch code from URL
114+
const params = new URLSearchParams(document.location.search)
115+
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)
124+
}
112125
});

0 commit comments

Comments
 (0)