【发布时间】:2018-11-06 10:49:50
【问题描述】:
我创建了一个 firebase 函数,用于在进行 API 调用时更新 firebase 数据库中的值。它给出了以下错误。
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions@ lint /home/sumedhe/Project/mobile-atm-server/functions
> tslint --project tsconfig.json
ERROR: /home/sumedhe/Project/mobile-atm-server/functions/src/index.ts[12, 5]: Promises must be handled appropriately
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ lint: `tslint --project tsconfig.json`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sumedhe/.npm/_logs/2018-05-27T20_11_58_855Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
代码
import * as express from "express";
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
const app = express();
admin.initializeApp();
app.get("/mytransactions/", async function getUser(req: express.Request, res: express.Response) {
// HERE IT GIVES THE ERROR //
admin.database().ref('/modified').set("yes");
});
exports.api = functions.https.onRequest(app);
但如果我将相同的代码与 firebase 数据库触发器一起使用,效果会很好。
exports.touch = functions.database.ref('/transactions/{item}').onWrite(
(change, context) => admin.database().ref('/modified').set("yes"));
【问题讨论】:
-
请编辑您的问题以显示整个错误。您错过了 lint 错误。
-
我修改了问题
标签: node.js typescript firebase firebase-realtime-database google-cloud-functions