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

Pull code from remote source #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Pull code from remote source
  • Loading branch information
faraazahmad authored Oct 16, 2023
commit dfeaeb3ea2f9e8b4357fec344aae4a902efa9f0d
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,17 @@ Promise.all([
});

toggles.querySelector("select").removeAttribute("disabled");

// fetch code from URL
const params = new URLSearchParams(document.location.search)
const sourceURL = params.get('source')
try {
const response = await fetch(new URL(sourceURL))
if (response.status === 200) {
const data = await response.text()
editor.setValue(data)
}
} catch (error) {
console.error(error)
}
});