'Property 'concatMap' does not exist on type 'Observable
Please help, i am trying to send a put request from Angular...when i try to use concatMap i get the error
public updateUser(token: string, requestBody: any): Observable<User> {
const myHeaders = new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token });
return this.http.put<User>(this.baseUrl + "api/user", requestBody, { headers: myHeaders }).concatMap(data => {
return of(data);
});
}
I get the below error..please anyone knows what i am doing wrong
Property 'concatMap' does not exist on type 'Observable<User>'.
I have tried the following, nothing worked, still same error
import 'rxjs/add/operator/concatMap';
import { concatMap } from 'rxjs/operators';
Solution 1:[1]
I was able to solve this by adding pipe to my code
public updateUser(token: string, requestBody: any): Observable<User> {
const myHeaders = new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token });
return this.http.put<User>(this.baseUrl + "api/user", requestBody, { headers: myHeaders })
.pipe(
concatMap(data => {
return of(data);
})
);
}
Solution 2:[2]
I would still prefer mongoDB and create a better schema structure. And use aggregate functions to retrieve data.
User schema -> DailyKeys schema
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shine odigie |
| Solution 2 | Sanmitra Nagaraj |
