Redux API Saga - React API calls made simple
Takes in a config and gives you a ready to use reducer saga and a common action. Avoid writing unnecessary boilerplate code. Github -> redux-api-saga
Example code which makes an API call to localhost:3001/puppyJpg/20345?resolution=HD
config --->
[{
path: 'localhost:3001/puppyJpg/:imageId',
method: 'GET',
name: 'puppyJpg',
mode: 'takeLatest',
initialResult: '',
}]
Usage --->
this.props.dispatch(action({
name: 'puppyJpg',
payload: {},
params: { imageId: 20345 },
query: { resolution: 'HD' },
onSuccess: () => {},
onError: (error) => {
console.error(typeof error === 'string' ? error : error.message);
};
}));