I'm building a like/dislike system for posts on my website. Every time the user clicks on the like button, the number of likes gets updated in the database. The object stored in the database has a url of the image, a category and the number of likes as its keys.
Following is my update code: likedButton(img) is a function which is called when the user clicks the like button.
likedButton(img) {
var url = img.src;
var x = this.db.list('/userPosts',
ref => ref.orderByChild('url').equalTo(url));
x.valueChanges().subscribe(
(datas) => {
var likes = datas[0]['likes'];
likes++;
this.db.object('/userPosts/'+datas[0]['url']).set({
'likes' : likes
})
console.log(likes);
});
}
I'm getting the following error: Reference.child failed: First argument was an invalid path = "/userPosts/https://firebasestorage.googleapis.com/v0/b/imageupload-d68a0.appspot.com/o/angfire2store%2Fpic488482?alt=media&token=be196b87-aa7e-4ed4-8092-a84845b885be". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
Please help!