Reputation: 33
I am working on a mobile App with Flutter and Firebase. My authentication is working fine.
Now, the user should send his name to the firebase. This is also working fine, however if he wants to update his name a new entry is generated instead of overwriting his name.
I tried http.put and http.patch, but in both cases a new entry is generated and the userID is lost.
Here is my Code:
void setName(String name) {
const url =
'https://name.europe-west1.firebasedatabase.app/profiles.json';
http.post(url, body: json.encode({'title': name, 'description': name}));
}
And my change name method
void changeName(String name) {
const url =
'https://name.europe-west1.firebasedatabase.app/profiles.json';
http.put(url, body: json.encode({'title': 'Ein Titel', 'description': name}));
}
Upvotes: 0
Views: 35
Reputation: 864
This should've been a comment but i think http.patch
would do just fine.
See the Firebase documentation for its REST API on updating data for more information.
Upvotes: 1