Typescript Firebase云功能的本地测试失败

Typescript Firebase云功能的本地测试失败,typescript,firebase,google-cloud-functions,firebase-cli,Typescript,Firebase,Google Cloud Functions,Firebase Cli,我想在我的本地计算机上测试我的简单云功能,这样我就不必每次更改代码时都部署它 我已经重新登录到firebase,现在使用firebase shell调用函数 这是我的云函数代码,但到目前为止我还没有执行它 export const getPossibleFriend = functions.region('europe-west1').https.onCall((data, context) => { console.log(data); const json = JSON

我想在我的本地计算机上测试我的简单云功能,这样我就不必每次更改代码时都部署它

我已经重新登录到firebase,现在使用firebase shell调用函数

这是我的云函数代码,但到目前为止我还没有执行它

export const getPossibleFriend = functions.region('europe-west1').https.onCall((data, context) => {
    console.log(data);
    const json = JSON.parse(data);
    console.log(data);
    console.log(json);
    console.log("OAHOIODHSDHHID")
    let test:string;
    const parentRef = admin.database().ref("users");

    return parentRef.once('value').then(snap => {
        snap.forEach(function(child) {
            if(child.child("nickname").val() === json["nickname"]){
                console.log(child.val());
                test = child.val();

            }
        });
    }).catch(reason => {
        console.log(reason);
    }).then(() => {console.log(test);return test}).catch(reason => {
        console.log(reason);
    });

});
每次使用firebase函数时:shell和call: getPossibleFriend({“数据”:{“昵称”:“某些字符串”},“上下文”:{“asdf”:“asdf”}})

我得到:

firebase > i  Your code has been provided a "firebase-admin" instance.  [object Object]  Unhandled error SyntaxError: Unexpected token o in JSON at position 1
     at JSON.parse (<anonymous>)
     at exports.getPossibleFriend.functions.region.https.onCall (/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/lib/index.js:451:23)
     at Object.<anonymous> (/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:330:32)
     at Generator.next (<anonymous>)
     at /Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:28:71
     at new Promise (<anonymous>)
     at __awaiter (/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:24:12)
     at func (/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:294:32)
     at corsHandler (/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:350:44)
     at cors (/Users/skyy/Documents/GitHub/Waste-
Less->Lifefirebasetypescript/functions/node_modules/cors/lib/index.js:188:7)

RESPONSE RECEIVED FROM FUNCTION: 500, {
  "error": {
    "status": "INTERNAL",
    "message": "INTERNAL"
  }
}
firebase>i您的代码已被提供一个“firebase admin”实例。[object object]未处理的错误SyntaxError:JSON中位置1处的意外标记o
在JSON.parse()处
位于exports.getPossibleFriend.functions.region.https.onCall(/Users/skyy/Documents/GitHub/Waste Less Life/firebasetypescript/functions/lib/index.js:451:23)
反对。(/Users/skyy/Documents/GitHub/Waste-Less-Life/firebasetypescript/functions/node_modules/firebase-functions/lib/providers/https.js:330:32)
在Generator.next()处
at/Users/skyy/Documents/GitHub/Waste Less Life/firebasetypescript/functions/node_modules/firebase functions/lib/providers/https.js:28:71
在新的承诺()
在等待者(/Users/skyy/Documents/GitHub/Waste Less Life/firebasetypescript/functions/node_modules/firebase functions/lib/providers/https.js:24:12)
在func(/Users/skyy/Documents/GitHub/Waste Less Life/firebasetypescript/functions/node_modules/firebase functions/lib/providers/https.js:294:32)
在corsHandler(/Users/skyy/Documents/GitHub/Waste Less Life/firebasetypescript/functions/node_modules/firebase functions/lib/providers/https.js:350:44)
在cors(/Users/skyy/Documents/GitHub/Waste)-
Less->Lifefirebasetypescript/functions/node_modules/cors/lib/index.js:188:7)
收到的功能响应:500{
“错误”:{
“状态”:“内部”,
“消息”:“内部”
}
}