Ad

Firebase: Getting A Weird `e` Object When Performing A Get

- 1 answer

Not sure what this is supposed to be or why it's happening, but I am trying to do a simple get on a collection I have in Firebase, however am getting the following object:

e {_firestore: o, _key: e, _document: e, _fromCache: false, _hasPendingWrites: false}
exists: true
id: "tOswoypflMS1gBPpfWmEenldBPm2"
metadata: t
ref: n
_document: e {key: e, version: n, data: a, proto: {…}, hasLocalMutations: false, …}
_firestore: o {_queue: t, INTERNAL: {…}, _config: Gc, _databaseId: e, _dataConverter: t, …}
_fromCache: false
_hasPendingWrites: false
_key: e {path: e}
__proto__: Object

It turns out I can't even do a JSON.stringify on as it causes the following error:

index.js:1375 TypeError: Converting circular structure to JSON

--> starting at object with constructor 'e'

| property 'firebase_' -> object with constructor 'Object'

| property 'apps' -> object with constructor 'Array'

--- index 0 closes the circle

Is there an issue with my schema or something that I am simply not understanding? My call is as follows:

  import { db } from '../firebase'

  const clients =  await db
        .collection('clients')
        .doc('A_VALID_CLIENT_ID')
        .get()

Ad

Answer

The result of a get() is a DocumentSnapshot, not a plain data object. You probably want to do any serialization on .data() from the snapshot instead.

Ad
source: stackoverflow.com
Ad