0
async function userName(user_Id) {
  let formData = {
    user_Id: user_Id,
  };
  let result = await apiResponse("getEmployeeNameByEmpId", "Post", formdata);
  return result;
}

return (
  <tr>
    <th>{userName(16)}</th>
  </tr>
);

Getting promise while calling the function in table header. And I thought to use .then to resolve promise but I have to create multiple useState because I am trying to use same function in multiple table header with different userid

dev321
  • 13
  • 3
  • TLDR; you can't return a value from an async function. An async function always returns a promise. – jabaa Mar 05 '23 at 20:02
  • you are using `async..await` incorrectly. your function is **exactly** the same as `function userName(user_Id) { return apiResponse("getEmployeeNameByEmpId", "Post", {user_Id}) }` – Mulan Mar 05 '23 at 20:05

0 Answers0