Alokit Nigam
Alokit Nigam

Reputation: 48

error TypeError: Path must be a string. Received undefined in firebase http request

I have added a http request in firebase functions which runs perfectly when it is run locally.

But after deploying it gives the error:

error TypeError: Path must be a string. Received undefined

Here's the code I am using for deleting records:

 exports.deleteoldposts =functions.https.onRequest((request,response)=> 
    {
     var now = Date.now();
     var cutoff = now - 5 * 60 * 1000;
      admin.firestore().collection("topic_database")
     .orderBy('timeInMills')
      .endAt(cutoff)
      .get()
      .then(function(docRef){
        docRef.forEach(docs => {
         console.log(docs.id,docs.data().userId);
         var postId=docs.id;
         var posterId = docs.data().userId;
         docs.ref.delete()
      })
      response.status(200).json("Deleted Succesfully");

      return 0;
    })
    .catch(function(error){
      console.log("error "+error);
      response.status(400).json(error);
    });
     });

Any help would be appreciated.

Upvotes: 2

Views: 676

Answers (1)

i have same issue, i have solved by updating firebase-admin to latest version

npm install firebase-admin@latest

(i don't have enough reputation that's why i am not able to comment)

Upvotes: 1

Related Questions