A helper function to create a query encoder from urlPropsQueryConfig
.
config
(Object): TheurlPropsQueryConfig
object, see urlPropsQueryConfig for details.
(Function): A function which, given an object with decoded parameters, returns the encoded equivalent.
const urlPropsQueryConfig = {
foo: { type: UrlQueryParamTypes.number, queryParam: 'fooInUrl' },
bar: { type: UrlQueryParamTypes.string },
};
const encode = urlQueryEncoder(urlPropsQueryConfig);
encode({ foo: 137, bar: 'str' });
// === { fooInUrl: '137', bar: 'str' }