score:2

Accepted answer

The await operator is used to wait for a Promise.

So in order to await signup() in handleSubmit, the signup function itself needs to return a promise. eg

function signup(name, e, p) {
  return axios
    .post("/register", {
      username: name,
      email: e,
      password: p,
    })
    .then(function (response) {
      console.log(response.data[0]);
      return response.data[0]; //"dear user, please check etc..."
    });
}

Related Query

More Query from same tag