Reputation: 69
I am running into a weird issue with firestore / Firebase.
Here is my code to fetch data from my Firestore DB:
firestore
.collection("questions")
.get()
.then(questions => {
console.log(questions)
}
When I console.log the questions
variable while running the web app on my local machine (localhost), it returns the following object:
t {im: t, pm: t, ym: t, om: undefined, bm: null, …}
bm: null
docs: (...)
empty: (...)
im: t {xT: FirebaseAppImpl, BT: t, INTERNAL: {…}, OT: t, WT: "[DEFAULT]", …}
metadata: t {hasPendingWrites: false, fromCache: false}
om: undefined
pm: t {path: n, collectionGroup: null, Ve: Array(0), filters: Array(0), limit: null, …}
query: (...)
size: (...)
vm: null
ym: t {query: t, docs: t, cs: t, docChanges: Array(563), _s: t, …}
__proto__: Object
However, when I console.log the same question
variable on my live deployed production site, it returns the following object:
t {_firestore: t, _originalQuery: t, _snapshot: t, _cachedChanges: null, _cachedChangesIncludeMetadataChanges: null, …}
docs: (...)
empty: (...)
metadata: t {hasPendingWrites: false, fromCache: false}
query: (...)
size: (...)
_cachedChanges: null
_cachedChangesIncludeMetadataChanges: null
_firestore: t {_firebaseApp: t, _queue: t, INTERNAL: {…}, _databaseId: t, _persistenceKey: "[DEFAULT]", …}
_originalQuery: t {path: e, collectionGroup: null, explicitOrderBy: Array(0), filters: Array(0), limit: null, …}
_snapshot: t {query: t, docs: t, oldDocs: t, docChanges: Array(563), mutatedKeys: t, …}
__proto__: Object
Namely, the production log has a _snapshot variable whereas my local log has a ym variable. Both have the "docChanges" variable which I am using to fetch the actual documents, but I am running into issues where it works on my live site but not on my local machine (or vice versa).
Does anyone know why the same variable is returning different objects in different environments? Or how to work around this?
Upvotes: 0
Views: 627
Reputation: 598847
On one environment you're likely running the code with access to a so-called source map, which shows that it shows the internals of the objects in a sort-of debug view. On the production environment the source maps are likely not available, which means you see the raw, minified code.
All of this doesn't matter if you keep yourself to using the documented API of the QuerySnapshot
class, which is available in both environments.
Upvotes: 2