Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
load user.mail from Auth0 with async function

i want load the user.mail from Auth0 and safe there at a const. but I get a arrow. i don't see the error. can somebody help me to find the solution?

const userMailInfo = async () => {


 auth0Client = await auth.createClient();

  const result = await auth0Client.getUser().then(user => {
    console.log('mail', user.email);
    user.mail;
  });
  return result;
}

;(async () => {
  const users = await userMailInfo()
  console.log(users)
})()

i get follow error:

(node:19676) UnhandledPromiseRejectionWarning: ReferenceError: document is not defined
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like these errors are caused by code running on the server-side, where they do not have access to 'document' and the like. In SvelteKit, endpoints always run on the server, and therefore do not have access to all the elements in the 'Client API'.

To guard code from running on the server side, try calling it through OnMount(). I've linked a Sapper issue outlining some similar solutions, e.g., using if(process.browser). I am not sure if this works in SvelteKit, but may be worth checking out.

Note: It seems like the error occured outside of the provided code snippet.


  • SvelteKit Discord Server contains some discussions on the topic, try searching for 'UnhandledPromiseRejectionWarning ReferenceError'.
  • (for Sapper) https://github.com/sveltejs/sapper/issues/1226
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!