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

88
Views
Why the given javascript code(log=>"ASDF") inside async block is executing twice , whereas the other statement (log=>"asdf once ") is executed once?

The caller is from the reducer i am using for the app to dispatch actions for changing the state of the app

The fn

const AddFriendFirebase = async (name = "", current_uid) => {
  console.log("ASdf one");
  const { uid } = await getUserFromName(name);
  console.log("ASdf");
  createMessageDoc(current_uid, uid);
}

The caller

case ADD_FRIEND: {
  AddFriendFirebase(payload, state.current_uid);
  return state;
}

get UserFromName Fn

const getUserFromName = async (name) => {
  console.log("get name fn");
  const q = query(collection(db, "users"), where("user_name", "==", name));
  const snapshot = await getDocs(q);
  if (!snapshot.docs[0]) {
    throw console.error("user not found!");
  }
  const user = snapshot.docs[0].data();

  return user;
};
about 4 years ago · Juan Pablo Isaza
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!