Reputation: 9123
My Cloud Functions node.js file is presenting this error:
477:4 error Each then() should return a value or throw
However I am returning a value in the then()
, (i'm returning 1
)
Line 477 is the line with if (snapshot.exists){
staging.js
function manuallyDeleteObj(objDoc, fcmToken){
return objDoc.get().then(snapshot => {
if (snapshot.exists){
return objDoc.delete().then(() => {
return 1;
}).catch(() => {
return 0;
})
}
else {
const dataMsg = { data: { type: "delete" } }
if ( !isNullOrUndefined(fcmToken) ) {
return admin.messaging().sendToDevice(fcmToken, dataMsg, options);
}
}
})
.catch(() => {
return 0;
})
}
Any idea what the problem is?
Upvotes: 0
Views: 57
Reputation: 317487
There is a code path that doesn't return a value. Try filling in the space where my question is below:
const dataMsg = { data: { type: "delete" } }
if ( !isNullOrUndefined(fcmToken) ) {
return admin.messaging().sendToDevice(fcmToken, dataMsg, options);
}
else {
// what do you want to return here?
}
Upvotes: 3