Created
July 29, 2023 16:48
-
-
Save rofe/8357f72407683cf4bd27c5d364b71af7 to your computer and use it in GitHub Desktop.
sidekick custom view: scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
try { | |
// get the resource URL from the url query parameter | |
const url = new URL(window.location.href).searchParams.get('url'); | |
if (url) { | |
const res = await fetch(url); | |
if (res.ok) { | |
const text = await res.text(); | |
const data = JSON.parse(text); | |
// do something with the data | |
} else { | |
throw new Error(`failed to load ${url}: ${res.status}`); | |
} | |
} | |
} catch (e) { | |
console.error('error rendering view', e); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment