How to read data from Firebase database? I have realtime firebase database with the following json file
{
"Category" : {
"Breakfast" : {
"CategoryImg" : "Breakfast-img",
"CategoryName" : "Breakfast"
},
"Gluten-Free" : {
"CategoryImg" : "Gluten-free-img",
"CategoryName" : "Gluten-free"
},
"Lunch" : {
"CategoryImg" : "Lunch-img",
"CategoryName" : "Lunch"
},
"Popular" : {
"CategoryImg" : "Popular-img",
"CategoryName" : "Popular"
},
"Trending" : {
"CategoryImg" : "Trending-img",
"CategoryName" : "Trending"
},
"Vegetarian" : {
"CategoryImg" : "Vegetarian-img",
"CategoryName" : "Vegetarian"
}
}
}
I'm using this code to retrieve the details
// 1
let rootRef = Database.database().reference()
// 2
let childRef = Database.database().reference(withPath: "Category")
// 3
let itemsRef = rootRef.child("Category")
// 4
let breakfastRef = itemsRef.child("Breakfast")
// 5
print(rootRef.key)
print(childRef.key)
print(itemsRef.key)
print(breakfastRef.key)
but I'm getting the following in the console. Can someone please help?
nil
Optional("Category")
Optional("Category")
Optional("Breakfast")
I'm following this tutorial but I'm unable to get the same result https://www.raywenderlich.com/3-firebase-tutorial-getting-started