繁体   English   中英

我不断收到 Error Unexpected token '?' 使用 NodeJS 和 Firebase 函数时

[英]I keep gettings the Error Unexpected token '?' when using NodeJS and Firebase Functions

我不断收到 Error Unexpected token '?' 使用 NodeJS 和 Firebase 函数时。 我没有任何 '?' 我的代码中的标记,所以认为它在 node_modules 中。 我在下面粘贴了我的代码。

const functions = require("firebase-functions");

const express = require('express');
const fs = require('fs');
const app = express();

// 99 Names of Allah
app.get('/99Names', (req, res) => {
  res.send(JSON.parse(fs.readFileSync('99namesofallah.json')));
});

// Duas
app.get('/duas', (req, res) => {
  res.send(JSON.parse(fs.readFileSync('dua/duas.json')));
});

app.get('/duas/:edition', (req, res) => {
  const edition = req.params.edition;
  res.send(JSON.parse(fs.readFileSync(`dua/${edition}.json`)));
});



app.listen(3000, () => {
  console.log('API listening on port 3000');
});

exports.app = functions.https.onRequest(app)

我尝试对我的代码进行配对并检查包,但无法找到“?” 令牌。

对于遇到此问题的任何其他人。 似乎 Firebase 函数和 NodeJS 放在一起不喜欢可选值。 我不得不编辑一些文件,并将可选的更改为 null/undefined 检查。

以下是我发现错误的文件:

  • firebase-app.js
  • firebase-namespace.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM