ANISUNDAR
ANISUNDAR

Reputation: 807

How to update firebase

I am using ionic 2.

I need update data into firebase using Firebase 3

Here is my code.

import firebase from 'firebase';

    up()
  {
     var v=this.Editflat.value;
     firebase.database().ref('/flats').update(this.key,v).then(res=>
     {console.log("UPDATED",res)});

  }

I am getting this error

Error: Firebase.update failed: First argument  must be an object containing the children to replace.

How can I fix this issue?

Kindly advice me,

Thanks.

Upvotes: 2

Views: 444

Answers (1)

Rax Weber
Rax Weber

Reputation: 3780

I presume this is what you want:

var v = this.Editflat.value;
firebase.database().ref('/flats/' + this.key).update(v).then(res => {
    console.log("UPDATED",res)
});

The variable v should be an Object. You can read more about it here.

Upvotes: 1

Related Questions