簡體   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