close

[Solved] Await is a reserved word error inside async function

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Await is a reserved word error inside async function in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Await is a reserved word error inside async function Error Occurs?

Today I get the following error Await is a reserved word error inside async function in javascript.

How To Solve Await is a reserved word error inside async function Error ?

  1. How To Solve Await is a reserved word error inside async function Error ?

    To Solve Await is a reserved word error inside async function Error Update the version of nodeJs. It will resolve your issue(9/9+)

  2. Await is a reserved word error inside async function

    To Solve Await is a reserved word error inside async function Error Update the version of nodeJs. It will resolve your issue(9/9+)

Solution 1

In order to use await, the function directly enclosing it needs to be async. According to your comment, adding async to the inner function fixes your issue, so I’ll post that here:

export const sendVerificationEmail = async () =>
  async (dispatch) => {
    try {
      dispatch({ type: EMAIL_FETCHING, payload: true });
      await Auth.sendEmailVerification();
      dispatch({ type: EMAIL_FETCHING, payload: false }))
    } catch (error) {
      dispatch({ type: EMAIL_FETCHING, payload: false });
      throw new Error(error);
    }
  };

Possibly, you could remove the async from the outer function because it does not contain any asynchronous operations, but that would depend on whether the caller of that sendVerificationEmail is expecting sendVerificationEmail to return a promise or not.

Solution 2

Update the version of nodeJs. It will resolve your issue(9/9+)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment