Created
September 5, 2019 08:02
-
-
Save shulcsm/9892002392b55a85ace1d0932459722b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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