Не удается получить /.../api/item/item_id - PullRequest
0 голосов
/ 16 февраля 2020

В настоящее время я создаю веб-приложение с использованием firebase, и когда я набираю:

http://localhost:5000/app/asia-northeast1/api/items/

, он возвращает правильные элементы. Но когда я делаю

http://localhost:5000/app/asia-northeast1/api/items/item_id

, он возвращает Cannot Get http://localhost:5000/app/asia-northeast1/api/items/item_id

Кто-нибудь знает почему?

Вот код функции get:

exports.getQuestion = (req, res) => {
  let questionData = {};
  db.doc(`/questions/${req.params.questionId}`)
    .get()
    .then(doc => {
      if (!doc.exists) {
        return res.status(404).json({ error: "Question not found" });
      }
      questionData = doc.data();

      questionData.questionId = doc.id;
      return db
        .collection("comments")
        .where("questionId", "==", req.params.questionId)
        .get();
    })
    .then(data => {
      questionData.comments = [];
      data.forEach(doc => {
        questionData.comments.push(doc.data());
      });
      return res.json(questionData);
    })
    .catch(err => {
      console.error(err);
      res.status(500).json({ error: err.code });
    });
};

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...