Skip to content

Instantly share code, notes, and snippets.

@alex-okrushko
Created December 6, 2018 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-okrushko/ea1a8784b7d48b5f52050ad6b6d5e00c to your computer and use it in GitHub Desktop.
Save alex-okrushko/ea1a8784b7d48b5f52050ad6b6d5e00c to your computer and use it in GitHub Desktop.
most basic API call
@Effect()
fetchProducts: Observable<Action> = this.actions$.pipe(
ofType<actions.FetchProducts>(actions.FETCH_PRODUCTS),
switchMap(() =>
this.productService.getProducts().pipe(
map(products => new actions.FetchProductsSuccess(products)),
catchError(() => of(new actions.FetchProductsError()))
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment