Created
September 6, 2021 12:01
-
-
Save mtt87/129ec5d99029958a83311cd0f29abb42 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 'navigator.locks' | |
export async function getSession(ctx) { | |
if (typeof window === 'undefined') { | |
const session = await _fetchData("session", ctx) | |
return session | |
} | |
return navigator.locks.request('NEXT_AUTH:GET_SESSION', async () => { | |
const session = await _fetchData("session", ctx) | |
if (ctx?.triggerEvent ?? true) { | |
broadcast.post({ event: "session", data: { trigger: "getSession" } }) | |
} | |
return session | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment