I’m trying to create a blog where i get the information from Firestore database. But I keep getting this error. TypeError: Cannot read property 'appendChild' of null
.
Here is the Firestore Database:
Advertisement
Answer
I think the error you are getting isn’t related to Firebase at all but rather to document.querySelector
on line 16. The function expects a valid CSS selector to be passed, so if you want to find element by id you should prepend selector with “#”. In your case there is also a typo so at the end it should look like this to work:
let postCollection = document.querySelector('#post-collection');
See https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector