Firebase firestore cloud functions showing Error: Invalid use of type “undefined” as a Firestore argument

后端 未结 3 477
独厮守ぢ
独厮守ぢ 2021-01-07 17:05

I have a project to add currency details into the firestore database and my project is doing with ionic 3

Whenever I add a new document to the collection a trigger f

3条回答
  •  误落风尘
    2021-01-07 17:55

    When you .set an object but one of the fields in the object is undefined you will get this error.

    The problem is that when you use console.log to display the object it does not show the undefined variables so it is difficult to trace.

    Use the following instead of console.log to find the element that is causing the problem.

    const util = require('util');
    console.log(util.inspect(myObject, {showHidden: false, depth: null}));
    

    This will give you an output as follows:

    { origin: 'AMS',
      destination: undefined,
      duration: 94,
      carrier: 'KL',
      flight_number: '2977',
      departure: '2019-06-11T15:34:00',
      arrival: '2019-06-11T17:08:00',
      type: 'flight' }
    

提交回复
热议问题