Skip to content

Instantly share code, notes, and snippets.

@Ron-Lavi
Created April 3, 2019 09:11
Show Gist options
  • Save Ron-Lavi/4dedc8e8456c06cded770c7c818c38f0 to your computer and use it in GitHub Desktop.
Save Ron-Lavi/4dedc8e8456c06cded770c7c818c38f0 to your computer and use it in GitHub Desktop.
api middleware
export const fetchData = () => ({
path: '/data',
method: 'GET',
query: { srach: 'some-search' },
debounce: 300,
baseConst: 'AUTO_COMPLETE',
finalizeRespnse: (response) => response.data.myData
});
export const createApiSelectors = (controller) => ({
selectResults: (state) => state[controller].results,
selectResults: () => null,
selectResults: () => null,
});
const { selectResults: selectAutoCompleteResults } = createApiSelectors('AUTO_COMPLETE');
export selectAutoCompleteResults;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment