How to use the qs.stringify function in qs

To help you get started, we’ve selected a few qs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mserajnik / hyve / services / web / src / components / files / Search.vue View on Github external
/*
       * The error is not handled because the `this.$router.replace()` call is
       * only used to replace the current URL, no navigation is expected.
       * vue-router can not navigate to the same URL again and errors as of
       * version 3.1.0.
       *
       * See https://github.com/vuejs/vue-router/issues/2872#issuecomment-519073998
       */
      this.$router.replace({
        path: '/files',
        query: query
      }).catch(err => {}) // eslint-disable-line handle-callback-err

      return {
        queryString: qs.stringify(query, { addQueryPrefix: true }),
        sanitizedQueryString: qs.stringify(
          sanitizedQuery, { addQueryPrefix: true }
        )
      }
    },
    loadFiles: function (fetchNextPage) {
github contiamo / restful-react / src / Get.tsx View on Github external
const makeRequestPath = () => {
      let url: string;
      if (__internal_hasExplicitBase) {
        url = composeUrl(base!, "", path || "");
      } else {
        url = composeUrl(base!, parentPath!, requestPath || path || "");
      }

      // We use ! because it's in defaultProps
      if (Object.keys(this.props.queryParams!).length) {
        url += `?${qs.stringify(this.props.queryParams)}`;
      }
      return url;
    };
github artsy / metaphysics / src / lib / helpers.ts View on Github external
export const toQueryString = (options = {}) =>
  /**
   * In the case of batched requests we want to explicitly _not_ sort the
   * params because the order matters to dataloader
   */
  // @ts-ignore
  options.batched
    ? stringify(options, {
        arrayFormat: "brackets",
      })
    : stringify(options, {
        arrayFormat: "brackets",
        sort: (a, b) => a.localeCompare(b),
      })
export const toKey = (path, options = {}) => `${path}?${toQueryString(options)}`
github mserajnik / hyve / services / web / src / components / tags / Search.vue View on Github external
/*
       * The error is not handled because the `this.$router.replace()` call is
       * only used to replace the current URL, no navigation is expected.
       * vue-router can not navigate to the same URL again and errors as of
       * version 3.1.0.
       *
       * See https://github.com/vuejs/vue-router/issues/2872#issuecomment-519073998
       */
      this.$router.replace({
        path: '/tags',
        query: query
      }).catch(err => {}) // eslint-disable-line handle-callback-err

      return {
        queryString: qs.stringify(query, { addQueryPrefix: true }),
        sanitizedQueryString: qs.stringify(
          sanitizedQuery, { addQueryPrefix: true }
        )
      }
    },
    loadTags: function (fetchNextPage) {
github walid1992 / martian-cli / template / weex / src / utils / modules / navigator.js View on Github external
function pushByUrl(url, query) {
  navigator.push({
    url: query ? `url?${qs.stringify(query)}` : url,
    animated: 'true'
  }, event => {
    console.log('callback: ', event)
  })
}
github casefoundation / analytics-dashboard / frontend / src / assets / store.js View on Github external
return new Promise((resolve, reject) => {
        const params = {}
        if (account) {
          params.account = account
        }
        if (property) {
          params.property = property
        }
        axios.get('/api/googleaprofiles?' + qs.stringify(params)).then((response) => {
          commit('SET_GOOGLE_ACCOUNTS', response.data.data)
          resolve()
        }, reject)
      })
    },
github GenesisVision / web-client / packages / shared / modules / programs-table / services / programs-table.service.ts View on Github external
export const programsChangeFilter = (filter: TFilter) => (
  dispatch: any,
  getState: any
) => {
  const { router } = getState();
  const queryParams = qs.parse(router.location.search.slice(1));
  if (filter.value === undefined) {
    delete queryParams[filter.name];
  } else {
    queryParams[filter.name] = filter.value;
  }
  if (queryParams.page) {
    delete queryParams.page;
  }
  const newUrl = router.location.pathname + "?" + qs.stringify(queryParams);
  dispatch(push(newUrl));
};
github pmg1989 / dva-admin / src / utils / request-mock.js View on Github external
export default function request (url, options) {
  if (options.cross) {
    const params = {
      q: `select * from json where url='${url}?${stringify(options.data)}'`,
      format: 'json',
    }
    url = `http://query.yahooapis.com/v1/public/yql?${stringify(params)}`
    options = 'get'
  }

  return fetch(url, options)
    .then(checkStatus)
    .then(handelData)
    .catch(handleError)
}
github feathersjs / feathers / packages / rest-client / lib / base.js View on Github external
getQuery (query) {
    if (Object.keys(query).length !== 0) {
      const queryString = qs.stringify(query);

      return `?${queryString}`;
    }

    return '';
  }
github victor-am / rails-ranger / src / path-builder.js View on Github external
_paramsToQuery ({ path, params }) {
    const snakeCaseParams = deepSnakeCaseKeys(params)
    const query = qs.stringify(snakeCaseParams, { encode: false })
    const pathWithQuery = query ? `${path}?${query}` : path

    return { path: pathWithQuery, params: {} }
  }
}

qs

A querystring parser that supports nesting and arrays, with a depth limit

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

91 / 100
Full package analysis