-
-
Save kangmingtay/c3559556033ba599f51182cf5956ac6c to your computer and use it in GitHub Desktop.
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
import { createClient } from "@supabase/supabase-js"; | |
const supabaseUrl = "your-project-ref"; | |
const supabaseKey = "your-anon-key"; | |
// Attempt to reproduce https://github.com/supabase/supabase-js/issues/805 | |
async function main() { | |
try { | |
const supabase = createClient(supabaseUrl, supabaseKey, { | |
auth: { | |
persistSession: false, | |
}, | |
}); | |
const { data, error } = await supabase.auth.signInWithPassword({ | |
email: "foo@example.com", | |
password: "secret123", | |
}); | |
if (error) throw error; | |
await supabase.auth.updateUser({ | |
data: { | |
colour: "red", | |
}, | |
}); | |
const { data: newSession, error: refreshSessionError } = | |
await supabase.auth.refreshSession(); | |
if (refreshSessionError) throw refreshSessionError; | |
console.log("First update: ", newSession.user.user_metadata); | |
await supabase.auth.updateUser({ | |
data: { | |
colour: "blue", | |
}, | |
}); | |
const { data: newSession2, error: refreshSessionError2 } = | |
await supabase.auth.refreshSession(); | |
if (refreshSessionError2) throw refreshSessionError2; | |
console.log("Second update: ", newSession2.user.user_metadata); | |
} catch (err) { | |
console.log("handling error"); | |
console.log(err); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment