Working with nested await in javascript
do this instead
let get_func = async (userId) => { let is_cached = await cache_user.findById(userId); if(!is_cached){ console.log("NOT CACHIED"); let is_dbuser = await db_user.find({}); console.log(is_dbuser); } else { console.log("CACHED"); } console.log("LEAVING get_func")};get_func(100);
please take note that it makes more sense to use findById unless it doesn't satisfy your query requirements and also async may require space before the parenthesis