I'm trying to return data from an async function to a non async function it always returns a promise here is my code
static async getById(id){
const db = await mongodb;
const mongoId = new ObjectID(id);
return await db.collection(Restaurant.collectionName).findOne({_id:mongoId});
}
const obj = Restaurant.getById(data);//called in a non async function so i cannot use await
return new Restaurant(obj);
as mentioned in the comment i cannot use await on the async function call so i need the async function getById to wait for the data before returning what should i do