Reputation: 233
I'm trying to write code that receives data from FireStore and passes it to UI. I have four nodes in total, three of which I have already made, but on the fourth node I get an error in the browser console:
Description.js
export class Description {
constructor(description = {}) {
this.id = description.id;
}
toString() {
return `
{this.id}|
`
}
}
export var DescriptionConverter = {
fromFirestore: function (snapshot, options) {
const data = snapshot.data(options);
return new Description(data);
}
};
Please tell me what I need to fix to avoid this error. If any additional code is needed for the answer, let me know
Upvotes: 0
Views: 89
Reputation: 464
Looks like it's failing on line 3 because it can't read id of null.
This means that description is null.
As we see in the error stack, this is being called by fromFirestore, so this means that data here is null.
In other words, the snapshot data is null, so I would either debug why you are getting empty snapshot data, or add error handling in this case.
Upvotes: 2