i’m trying to save user profile to firebase. but i’m getting this error
TypeError: this.profileObject.set is not a function
My data.provider is as follows
// import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AngularFireDatabase, FirebaseObjectObservable } from 'angularfire2/database-deprecated';
import { User } from 'firebase/app';
import { Profile } from './../../model/profile/profile.interface';
@Injectable()
export class DataProvider {
profileObject: FirebaseObjectObservable<Profile>;
constructor (private database: AngularFireDatabase) {}
async saveProfile (user: User, profile: Profile) {
this.profileObject = this.database.object(`/profiles/${user.uid}`);
try {
console.log(user.uid);
await this.profileObject.set(profile);
return true;
} catch (error) {
console.log(error);
return false;
}
}
}
My edit-profile-form is as follows
import { AuthProvider } from '../../providers/auth/auth';
import { DataProvider } from '../../providers/data/data.provider';
import { NavController } from 'ionic-angular';
import { Component } from '@angular/core';
import { Profile } from './../../model/profile/profile.interface';
import { Subscription } from 'rxjs/Subscription';
import { User } from 'firebase';
@Component({
selector: 'edit-profile-form',
templateUrl: 'edit-profile-form.html'
})
export class EditProfileFormComponent {
profile = {} as Profile;
private authenticatedUser$: Subscription;
private authenticatedUser: User;
constructor (
private navCtrl: NavController,
private auth: AuthProvider,
private data: DataProvider
) {
this.authenticatedUser$ = this.auth.getAuthenticatedUser().subscribe((user: User) => {
this.authenticatedUser = user;
});
}
async saveProfile () {
const result = await this.data.saveProfile(this.authenticatedUser, this.profile);
console.log(result);
}
navigateToPage (pageName: string) {
pageName === 'TabsPage' ? this.navCtrl.setRoot(pageName) : this.navCtrl.push(pageName);
}
}
How can i solve the problem?
How can i use updated ‘angularfire2/database’ instead of ‘angularfire2/database-deprecated’?