Skip to content

Instantly share code, notes, and snippets.

@KeKs0r
Created May 30, 2018 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeKs0r/4c35300de6b7de45cb6ffa80903900b6 to your computer and use it in GitHub Desktop.
Save KeKs0r/4c35300de6b7de45cb6ffa80903900b6 to your computer and use it in GitHub Desktop.
function queryMiddleware() {
return next => action => {
if (action && action[SIMPLE] !== undefined && action[SIMPLE].query) {
const request = action[SIMPLE];
const query = qs.stringify(request.query, {
arrayFormat: 'brackets',
encode: false
});
request.endpoint = [request.endpoint.replace(/\?*/, ''), query].join('?');
delete request.query;
return next({ [SIMPLE]: request });
}
return next(action);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment