✨feature: Add client-side fetch javascript
This commit is contained in:
18
app/src/scripts/fetch-prompts.js
Normal file
18
app/src/scripts/fetch-prompts.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// app/src/scripts/fetch-prompts.js
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
|
||||
const supabase = createClient(import.meta.env.PUBLIC_SUPABASE_URL, import.meta.env.PUBLIC_SUPABASE_ANON_KEY);
|
||||
|
||||
async function loadPrompts() {
|
||||
const { data, error } = await supabase.from('prompts').select('*');
|
||||
if (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now render them in the DOM
|
||||
const container = document.getElementById('prompt-list');
|
||||
container.innerHTML = data.map(prompt => `<li>${prompt.title}</li>`).join('');
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', loadPrompts);
|
||||
Reference in New Issue
Block a user