Skip to content

Instantly share code, notes, and snippets.

@rofe
Created July 29, 2023 16:48
Show Gist options
  • Save rofe/8357f72407683cf4bd27c5d364b71af7 to your computer and use it in GitHub Desktop.
Save rofe/8357f72407683cf4bd27c5d364b71af7 to your computer and use it in GitHub Desktop.
sidekick custom view: scripts.js
(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