0

For some reason this works

const docRef = doc(db, "users", "1");
const docSnap = await getDoc(docRef);
const currentWeek = docSnap.get('currentWeek')
const onLoadPage = docSnap.get('currentPage')

But this doesn't

function getCurrentPage() {
const docRef = doc(db, "users", "1");
const docSnap = await getDoc(docRef);
const currentWeek = docSnap.get('currentWeek')
};

It hangs up on the 'await' and the console says

Unexpected reserved word (Points to await)

Why does it work the first time but not the second? This happens all the time and I dont understand it

It seems to me that this is happening because await is being used consecutively. Await seems to work when used localy within things but if its used twice in a open area it doesn't seem to like it

Wan33
  • 163
  • 1
  • 12
  • `async function getCurrentPage() { const docRef = doc(db, "users", "1"); const docSnap = await getDoc(docRef); const currentWeek = docSnap.get('currentWeek') };` – Eduards May 16 '22 at 06:24
  • Thanks, I figured out that I need to use it within a async function – Wan33 May 17 '22 at 09:59

0 Answers0