i have my code with ionic 3 angular 5 working as below
getUser(uid:string){
console.log('start of getUser with uid:' + uid)
return new Promise((resolve, reject) =>
{
this.db.object("/users/" + uid).snapshotChanges().map(
(snapshot) => {return snapshot.payload.val()}
).subscribe(
res => {
console.log('response:' + res)
resolve(res)
},
err => {
console.log(err)
reject(err)
}
)
})
}
however, with ionic 4 .map does not work any more. how do i convert this code?
Just like you can see here
So now you can use
map()
like this:Not related to the question itself but just in case, if you want your
getUser()
method to return a promise, you can use RXJS operators as well (instead of creating and resolving a promise), like this: