Answer the question
In order to leave comments, you need to log in
How to edit firebase data?
I figured out so far only how to add and delete data to the db and receive them, but how to change existing data using request?
class ApiService {
constructor(baseUrl) {
this.url = baseUrl
}
async createComputer(computer){
try {
const request = new Request(this.url + '/computers.json', {
method: 'post',
body: JSON.stringify(computer)
})
return useRequest(request)
} catch (error){
console.error(error)
}
}
async fetchComputer() {
try{
const request = new Request(`${this.url}/computers.json`, {
method: 'get'
})
return useRequest(request)
} catch (error) {
console.error(error)
}
}
}
const apiService = new ApiService('https://my-linkr.firebaseio.com/')
Answer the question
In order to leave comments, you need to log in
To update / edit data, the put and patch methods are used there.
Put - if there is no record, it will create a new one, and if there is a record, it will overwrite all the data.
Patch - will add/remove/change data in a record without changing the record itself.
Examples
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question