I assume assignUser function is making an api call using fetch. So if you are not using the then catch method to resolve the promise, then the assignUser function has to be an async function.

async function assignUser(user) {
  try {
    const jsonRes = await fetch(url);
    if(!jsonRes.ok) {"message failure");
    } else {"message success");
       const result = await jsonRes.json();
       return result;
  } catch (e) {"message error");

Here you don't need another function to check the status and all and instead of checking with the status code you can use the response.ok property.

Hope this helps Thanks

Related Query

More Query from same tag