Let's assume that you have the following endpoint in Firebase:
javascriptlet lastPosts = { 'jdJDoljfNmc': { 'uid': 'JSkssLizO' } }
Suppose that you have another endpoint such as:
javascriptlet users = { 'JSkssLizO': { 'posts': { 'jdJDoljfNmc': { 'title': 'hello' 'message': 'hi' 'timestamp': 1638702647456 } } } }
The uid in lastPosts
is linked to the uid in users
. If you want to retrieve the data from an endpoint to another:
javascriptimport { db, get, onValue, ref } from 'firebase' onValue(ref(db, `lastPosts/${postId}`), async snapshot => { let { uid } = snapshot.val() let post = (await get(ref(db, `${uid}/posts/${postId}`))).val() // At th is point you have the post info })
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.