Skip to content

Instantly share code, notes, and snippets.

@shulcsm
Created September 5, 2019 08:02
Show Gist options
  • Save shulcsm/9892002392b55a85ace1d0932459722b to your computer and use it in GitHub Desktop.
Save shulcsm/9892002392b55a85ace1d0932459722b to your computer and use it in GitHub Desktop.
export function createActions<K extends keyof Actions>(
endpoint: string,
url: string,
actions: K[],
): Pick<Actions, K> {
const res: any = {};
if (actions.includes('item')) {
res['item'] = {
path: `${url}/:id`,
endpoint: {
endpoint: `${endpoint}:id/`,
method: 'GET',
},
}
}
return res as Pick<Actions, K> ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment