亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Firebase 函數,響應不是有效的 json 對象

Firebase 函數,響應不是有效的 json 對象

心有法竹 2023-04-20 10:50:53
我正在使用 android studio 開發一個基于角色的應用程序,因為我的項目需要管理員權限來創建用戶和刪除用戶我為我的項目使用了 firebase admin sdk。我試圖刪除多個帳戶,但我遇到了問題。響應返回無效的 json 對象。正如在我的代碼中,我試圖處理可能的錯誤。但是,響應仍然返回無效的 json 對象。 見下文索引.js    exports.deleteUser = functions.https.onCall(async (data,context) => {try {    if(!context.auth) {        throw new AuthenticationError('Kimlik Do?rulamas? Yap?lmam??');    }    const uids = JSON.parse(data);    console.log(uids);    const callerUid = context.auth.uid;    const callerUser = await admin.auth().getUser(callerUid);    if(!callerUser.customClaims.admin && !callerUser.customClaims.superadmin) {        throw new NotAnAdminError('Bu i?lemi sadece y?neticiler ger?ekle?tirebilir');    }     const reference = admin.firestore().collection("Users");    const res = await admin.auth().deleteUsers(uids);    res.errors.forEach(element => console.log(element));    const successes = res.successCount;    const fails = res.failureCount;    console.log(fails);    console.log(successes);    if(fails===0) {        await uids.forEach(element => reference.doc(element).delete());        return {result:successes+' ??renci Silindi!'};    }else {        throw new functions.https.HttpsError('Silme Hatas?','Bilinmeyen hata,         silinemeyen ??renci say?s?: '+fails);    }}    catch(error) {        if(error.type === 'NotAnAdminError') {            throw new functions.https.HttpsError('Bu i?lemi yapma yetkiniz              yok.',error.message);        }else if(error.type === 'AuthenticationError') {            throw new functions.https.HttpsError('Kimlik Hatas?',error.message);        }else {            throw new functions.https.HttpsError('internal ERROR from catch             block',error.message);        }     }});
查看完整描述

1 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

您的函數聲明并導出為“deleteUser”,但您在 Android 客戶端中將其調用為“deleteUsers”,這是不一樣的。字符串需要匹配。



查看完整回答
反對 回復 2023-04-20
  • 1 回答
  • 0 關注
  • 96 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號