From 1139cd34dc8affb6603be31e2bceb58818b662aa Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 11 Jun 2020 19:19:27 +0100 Subject: [PATCH] updated the return values of the cloud function --- functions/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/functions/index.js b/functions/index.js index 745744bfd..63437ab6b 100644 --- a/functions/index.js +++ b/functions/index.js @@ -327,21 +327,24 @@ exports.addTag = functions.https.onCall((request,response) => { try{ if(!isTagValid(request.name)){ - return -1; + return {status:-1}; }else{ return admin.firestore().collection(`users/${request.uid}/tags`).add({ name: request.name }).then(e => { console.log(`user ${request.uid} created a tag: ${request.name}`); - return 1; + return { + status:1, + id: e.id + }; }).catch(e => { console.error(`error while creating tag for user ${request.uid}: ${e.message}`); - return 0; + return {status:-999}; }) } }catch(e){ console.error(`error adding tag for ${request.uid} - ${e}`); - return -999; + return {status:-999}; } }) \ No newline at end of file