Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable `ignoreUndefinedProperties` in node js

I am developing a REST api for my application in Nodejs and Express. But each time i try to send a request I get an undefined error. Please how can i enable 'ignoreundefinedproperties'

like image 948
Adesuyi Ayodeji Avatar asked May 23 '20 09:05

Adesuyi Ayodeji


2 Answers

once you import the firebase-admin sdk (in Typescript) like this

import * as firestore from "firebase-admin"; 

then you just need to set the setting like this :

const db = firestore.firestore(); db.settings({ ignoreUndefinedProperties: true }) 
like image 200
Navneet kumar Avatar answered Oct 07 '22 04:10

Navneet kumar


If you are getting errors for calling this more than once, I recommend putting admin.firestore().settings({ignoreUndefinedProperties:true}); in the same place you have admin.initializeApp();

Here's how I did it in my Typescript project

initialize.ts:

import * as admin from 'firebase-admin'; import 'firebase-functions';   admin.initializeApp(); admin.firestore().settings({ignoreUndefinedProperties:true}); 

Top of index.ts:

import './initialize.ts' 
like image 27
kmoney12 Avatar answered Oct 07 '22 04:10

kmoney12