Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api call is not getting trigger if following links from the state #108

Open
sazyadav opened this issue Jun 30, 2023 · 0 comments
Open

api call is not getting trigger if following links from the state #108

sazyadav opened this issue Jun 30, 2023 · 0 comments

Comments

@sazyadav
Copy link

Hi @evert

we are trying to follow some of the links out of state and very first time when the page loads those links are not trigrring api call.

const refreshStore = (franchiseId: string, storeId: string) => {
franchiseGroupClient.get(franchiseId).then(response => setFranchiseGroup(response));
storeClient.get(franchiseId, storeId, true).then(({ data, state }) => {
if (state.links.has('region')) regionClient.fromResource(state.follow('region')).then(setRegion);
if (state.links.has('area')) areaClient.fromResource(state.follow('area')).then(setArea);
if (state.links.has('close')) setStoreCloseURL(state.links.get('close')!.href);
if (state.links.has('open')) setStoreOpenURL(state.links.get('open')!.href);
if (state.links.has('reopen')) setStoreReopenURL(state.links.get('reopen')!.href);
if (state.links.has('finalize')) setStoreFinalizeURL(state.links.get('finalize')!.href);
if (state.links.has('abandon')) setAbandonStoreURL(state.links.get('abandon')!.href);
setStore(data);
});
storeClient.assignments(storeId).then(setTeamRoster);
};

this is our fromREsource
fromResource = async (resource: Resource): Promise => resource.get().then(this.fromState);
abstract fromState(state: State): Promise;

so in regionClient.fromResource(state.follow('region')).then(setRegion); we are trying to follow the region link but at the pagload time it is not calling the api but when we refresh the page, api call is getting triggered..

COuld you please help me to call the api first time (at the page load only).. why after refresh it calls the api?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant