Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix example code to new signOut signUp

Duncan Healy950eeb65173f
diff --git a/examples/auth-vanilla-js/index.js b/examples/auth-vanilla-js/index.js
index 425ada24dd6..d1ae89a03f4 100644
--- a/examples/auth-vanilla-js/index.js
+++ b/examples/auth-vanilla-js/index.js
@@ -26,11 +26,11 @@ const signUpSubmitted = (event) => {
const password = event.target[1].value
supabase.auth
- .signup(email, password)
+ .signUp({email, password})
.then((response) => {
- document.querySelector('#access-token').value = response.body.access_token
- document.querySelector('#refresh-token').value = response.body.refresh_token
- alert("Logged in as " + response.body.user.email)
+ document.querySelector('#access-token').value = response.data.access_token
+ document.querySelector('#refresh-token').value = response.data.refresh_token
+ alert("Logged in as " + response.user.email)
})
.catch((err) => {
alert(err.response.text)
@@ -43,11 +43,11 @@ const logInSubmitted = (event) => {
const password = event.target[1].value
supabase.auth
- .login(email, password)
+ .signIn({email, password})
.then((response) => {
- document.querySelector('#access-token').value = response.body.access_token
- document.querySelector('#refresh-token').value = response.body.refresh_token
- alert("Logged in as " + response.body.user.email)
+ document.querySelector('#access-token').value = response.data.access_token
+ document.querySelector('#refresh-token').value = response.data.refresh_token
+ alert("Logged in as " + response.user.email)
})
.catch((err) => {
alert(err.response.text)
@@ -69,7 +69,7 @@ const logoutSubmitted = (event) => {
event.preventDefault()
supabase.auth
- .logout()
+ .signOut()
.then((response) => {
document.querySelector('#access-token').value = ''
document.querySelector('#refresh-token').value = ''
diff --git a/examples/live-tracker-map/pages/_app.js b/examples/live-tracker-map/pages/_app.js
index de0f1441785..c4b4d54c0a1 100644
--- a/examples/live-tracker-map/pages/_app.js
+++ b/examples/live-tracker-map/pages/_app.js
@@ -27,7 +27,7 @@ function MyApp({ Component, pageProps }) {
function onSignOut() {
try {
const user = auth.currentUser();
- user.logout()
+ user.signOut()
.then(response => {
console.log("User logged out")
window.location.reload()
diff --git a/examples/live-tracker-map/pages/api/auth/signup.js b/examples/live-tracker-map/pages/api/auth/signup.js
index 2d40a5041c6..b4615dc2bcb 100644
--- a/examples/live-tracker-map/pages/api/auth/signup.js
+++ b/examples/live-tracker-map/pages/api/auth/signup.js
@@ -4,7 +4,7 @@ export default async function (req, res) {
try {
const { email, password, role } = req.body
- const authBody = await auth.signup(email, password)
+ const authBody = await auth.signUp({email, password})
supabase.setAccessToken(authBody.access_token)
const { body: user } = await supabase.from('users').insert([{ id: authBody.user.id, username: email, role }]).single()