Async method as an expression in ternary expression

I’m trying to call an async method inside a ternary expression as a condition, yet the execution of the code isn’t working as expected. Could someone explain to me why this :

req.user.user_id === concept.owner_id
  ? async () => {
      console.log("here");
      const update = req.body;
      update.concept_id = conceptId;
      update.owner_id = concept.owner_id;
      const updatedConcept = await Concept.updateConcept(update);
      updatedConcept !== null
        ? ResponseSuccess.success(res, updatedConcept)
        : ResponseError.internalServerError(res);
    }
  : ResponseError.unauthorized(res);

Isn’t working? I verified that the condition is true. FYI ResponseSuccess and ResponseError are just response handlers and formatters. Is it because both parts are different types?

TIA

Answer

You are not calling the async function, you are just assigning it.

req.user.user_id === concept.owner_id
  ? (async () => {
      console.log("here");
      const update = req.body;
      update.concept_id = conceptId;
      update.owner_id = concept.owner_id;
      const updatedConcept = await Concept.updateConcept(update);
      updatedConcept !== null
        ? ResponseSuccess.success(res, updatedConcept)
        : ResponseError.internalServerError(res);
    })()                                              // Do this to call it
  : ResponseError.unauthorized(res);