In my async function, I can't get true priority output.
Expected result is firstly {control : 1} and then {control : 2}.
But the result is vice versa.
How can I make it true ?
NodeJS Code
edit_settings = async function (params) {
await User.updateOne({ _id: params.id }, query, (error, update_result) => {
console.log({ control : 1 });
if (error) return { success: false, error: { code: 1001 } };
else return { success: update_result.nModified };
});
return await { control : 2 };
}
NodeJS Result
{ control : 2 }
{ control : 1 }