Created
May 30, 2018 09:26
-
-
Save KeKs0r/4c35300de6b7de45cb6ffa80903900b6 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
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