actionsConfig
Properties
Example
const actionsConfig = {
create: {
// Mandatory
method: 'GET',
url: 'https://api.co/users/:userType/::userId/infos',
// Optional
cacheHint: (urlParams, query, body, otherArgs) => otherArgs.language,
beforeHook: (urlParams, query, body, otherArgs, dispatch) =>
console.log(
'User infos retrieved with query: ',
query,
'and with custom property: ',
otherArgs.property,
),
normalizer: ({ user }) => ({
entities: { users: { [user.id]: user } },
result: user.id,
}),
metadataNormalizer: ({ _meta }) => _meta,
afterHook: (
normalizedPayload,
urlParams,
query,
body,
otherArgs,
dispatch,
) => {
if (Object.values(normalizedPayload.users)[0].isCompleted) {
return dispatch(someAction());
} else {
console.log(otherArgs.otherProperty);
}
},
networkHelpers: {
getToken: () => 'custom_token',
},
},
};Tips
Last updated