I am Getting Error 9 Internal server error what is problem in code please help

// Fetch one scream
exports.getScream = (req, res) => {
  let screamData = {};
  db.doc(`/screams/${req.params.screamId}`)
    .get()
    .then((doc) => {
      if (!doc.exists) {
        return res.status(404).json({ error: 'Scream not found' });
      }
      screamData = doc.data();
      screamData.screamId = doc.id;
      return db
        .collection('comments')
        .orderBy('createdAt', 'desc')
        .where('screamId', '==', req.params.screamId)
        .get();
    })
    .then((data) => {
      screamData.comments = [];
      data.forEach((doc) => {
        screamData.comments.push(doc.data());
      });
      return res.json(screamData);
    })
    .catch((err) => {
      console.error(err);
      res.status(500).json({ error: err.code });
    });

Hey I am getting the same error. Were you able to solve it?

Itโ€™s because you are chaining โ€œ.orderBy(โ€˜createdAtโ€™, โ€˜descโ€™)โ€ to the request, you need to create an index for it to work, check your terminal, you will see the link you need to create an index

You should see something like :
The query requires an index. You can create it here: "https://.......""