Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 711 Bytes

urlQueryEncoder.md

File metadata and controls

26 lines (16 loc) · 711 Bytes

urlQueryEncoder(config)

A helper function to create a query encoder from urlPropsQueryConfig.

Arguments

  1. config (Object): The urlPropsQueryConfig object, see urlPropsQueryConfig for details.

Returns

(Function): A function which, given an object with decoded parameters, returns the encoded equivalent.

Examples

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' }