Created
May 1, 2021 14:57
-
-
Save emeraldjava/0541eaa0341605fa276048ac9ce91ab2 to your computer and use it in GitHub Desktop.
Running supabase js within a vanilla html page.
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
<html> | |
<header> | |
<title>Supabase</title> | |
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js"></script> | |
</header> | |
<body> | |
<h2>supabase</h2> | |
<script> | |
const { createClient } = supabase | |
supabase = createClient('https://dxxxxxz.supabase.co', 'api-key') | |
console.log('supabase'+supabase) | |
// use then() | |
supabase | |
.from('factor') | |
.select('*') | |
.limit(5) | |
.then(console.log) | |
.catch(console.error); | |
// use ananymous async/await functions | |
(async () => { | |
let { data, error } = await supabase | |
.from('event') | |
.select('*') | |
.limit(5) | |
if (error) { | |
console.log(error) | |
return | |
} | |
console.log(data) | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I wanted to thank you for this code. I’m new to Supabase and JS in general. I was able to finally learn how to take a Supabase table and display it on my page thanks to you. So thanks.