Get value out of an asynchronous function

PHOTO EMBED

Mon May 24 2021 14:58:36 GMT+0000 (UTC)

Saved by @shihor #javascript #asynchronousfunctions

  var getColumnName = async (err) => {
    var product = await ProductType.findOne({
      _id: productType,
    });
    if (err) {
      console.log('Something is wrong');
    }
    return product;
  };

  var columnName = await getColumnName();
content_copyCOPY