I'm working through the code in this repository React-powered Hacker News client and would like to modify this to use fetch
instead of the Hacker News firebase API specific code that is currently used (as a learning exercise).
This is the code requiring the firebase/app
and firebase/database
. Before I spend a lot of time on this is it feasible for me (with only basic Javascript/React experience) to update this to use fetch
instead of firebase proprietary code?
My understanding is that I could use fetch to retrieve the data i.e. something based on:
fetch('https://hacker-news.firebaseio.com/v0/')
.then(response => {
return response.json()
})
.then(data => {
// Work with JSON data here
console.log(data)
})
})
I'm not sure how I would emulate these kind of functions though as they as using firebase.database()
code.
function storiesRef(path) {
return api.child(path)
}
function itemRef(id) {
return api.child('item/' + id)
}
function userRef(id) {
return api.child('user/' + id)
}
function updatesRef() {
return api.child('updates/items')