在 SAP Spartacus 里如何调用 hybris 里实现的自定义 API
需求:We have a custom API created in hybris and I need to use the data returned by that custom API in some Spartacus pages. I want to do this post login and want to call that api whenever the page refreshes. Also I want to maintain the data in a state so that I can use it across the pages. I know how to do it in Angular but I am confused how to do it in Spartacus. Can someone please help me
-
登錄之后調用 api.
-
頁面刷新時調用 api.
答案
You should treat spartacus as external lib. If you know how implement it in Angular, just do it. Most of our actions like login are exported in public API:
import { ActivatedRouterStateSnapshot, AuthActions } from '@spartacus/core'; import { RouterNavigatedAction, ROUTER_NAVIGATED } from '@ngrx/router-store';@Injectable() export class YourEffects {@Effect()yourActionOnLogin$: Observable<YourActions.XXX> = this.actions$.pipe(ofType(AuthActions.LOGIN),map(() => new CheckoutActions.XXX()));@Effect()yourActionOnNavigation$: Observable<YourActions.YYY> = this.actions$.pipe(ofType<RouterNavigatedAction<ActivatedRouterStateSnapshot>>(ROUTER_NAVIGATED),map(() => new YourActions.YYY()));}You can create and provide own modules for part of ngrx store and occ adapters (API) as well.
總結
以上是生活随笔為你收集整理的在 SAP Spartacus 里如何调用 hybris 里实现的自定义 API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 皇室战争满级后金卡怎么搞(17173皇室
- 下一篇: 宏碁 X27U 显示器上架:27 英寸