Function searchParamsToString

  • Convert an object into a search param string. Note the following:

    • All non-string values are converted into strings.
    • Keys with undefined or null values will be omitted from the string.
    • To include a key without any value, set the key to an empty string.
    • The leading '?' is included in the return string.
    • If no key-value pairs are included, this returns an empty string.

    Parameters

    Returns string

    import {searchParamsToString} from 'url-vir';

    searchParamsToString({hello: ['there'], cheese: ['']}); // `'?hello=there&cheese'`