Hi I\'m trying to follow a tutorial on angular but the tutorial was made in September. I believe the person used angular-cli 1.3.2. I\'m not sure which version of rxjs he wa
pipe
is a method on Observable which is used for composing operators
Here is the way how you can use the new method pipe()
in Version 6:
loadProducts() {
return this.http.get("/api/products").
pipe(
map((data: any[]) => {
this.products = data;
return true;
}), catchError( error => {
return throwError( 'Something went wrong!' )
});
)
}
Keep in mind that with Version 6 you should now use catchError
and throwError
instead of:catch
and throw
. Here is the correct import with Version 6:
import { Observable, of, throwError, ...} from "rxjs"
import { map, catchError, ...} from "rxjs/operatros"