When utilizing async functions in my cloud function and including a 'return' statement in each potential output, I am still encountering the error message Not all code paths return a value
I attempted removing my database calls and only leaving the 'return {data:{...}};' to resolve the error.
Furthermore, I tried enclosing everything within a 'try' 'catch' block.
I currently have two blocks get().then()...catch().. which seems like it should work as expected.
export const getUsersInHere = functions.https.onCall((data, context) =>
{
if(!context || !context.auth || !context.auth.uid)
{
return {data:{message:"Please login again...", success:false}};
}
else if(data)
{
const my_uid = context.auth.uid;
db.collection(`InHere/${my_uid}`).get().then(snapshot =>
{
return {data:{}, success:true};
}).catch(e =>
{
return {data:{message:"No last message yet...", success:false}};
});
}
else
{
return {data:{message:"no body sent", success:false}};
}
});
Although I expect to deploy my cloud function with firebase deploy, I am receiving deployment errors:
src/index.ts:83:62 - error TS7030: Not all code paths return a value.
83 export const getUsersInHere = functions.https.onCall((data, context) =>
Note I discovered that 'firestore deploy' works when I added 'async' into the callable signature. However, the warning/error persists in Microsoft Visual Studio Code (Not all code paths return a value.ts(7030))
export const getUsersInThisChatRoom = functions.https.onCall(async (data, context) =>