How to use the query-string.parse function in query-string

To help you get started, we’ve selected a few query-string 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 SolidZORO / leaa / packages / leaa-dashboard / src / components / ErrorBoundary / ErrorBoundary.tsx View on Github external
componentDidCatch(error: Error, info: {}) {
    // TIPS: Many times DidCatch is because the JS file can't be retrieved, so refresh it first.
    const qs = queryString.parse(window.location.search);

    if (!qs[CATCH_HAS_REFRESH_URL_PARAM]) {
      window.location.href = urlUtil.mergeParamToUrlQuery({
        window,
        params: { [CATCH_HAS_REFRESH_URL_PARAM]: 1 },
        replace: false,
      });
    }

    console.log('---- ALL-STACK ----', info, error);

    this.setState({ errorInfo: error.message });
  }
github fidalgodev / movie-library-react / src / containers / Search.js View on Github external
const Search = ({
  geral,
  match,
  location,
  getMoviesSearch,
  clearMovies,
  movies,
}) => {
  const { query } = match.params;
  const params = queryString.parse(location.search);
  const { secure_base_url } = geral.base.images;

  // Fetch movies hook
  useFetchMoviesSearch(query, getMoviesSearch, params, clearMovies);

  // If loading
  if (movies.loading) {
    return ;
  }

  //If there are no results
  else if (movies.total_results === 0) {
    return (
github fastai / course-v3 / fastai-video-browser / src / App.jsx View on Github external
static getDerivedStateFromProps(props, state) {
    const parsed = qs.parse(window.location.search)
    // Parse selected lesson from query string, so we don't have to deal with real /routing.
    return { 
      ...state, 
      selectedLesson: parseInt(parsed.lesson) || 1,
      startAt: parseInt(parsed.t, 10) 
    }
  }
github jxnblk / stepkit / src / components / app.jsx View on Github external
componentDidMount: function() {
    var self = this;
    if (window) {
      var params = qs.parse(window.location.search);
      this.setState(params);
    }
    this.initBumpkit();
    if (document) {
      document.onkeydown = function(e) {
        //console.log(e.which);
        switch (e.which) {
          case 32:
            e.preventDefault();
            self.playPause();
            break;
          default:
            break;
        }
      };
    }
github zapier / redux-router-kit / src / utils / matchRoutes.js View on Github external
throw new Error('matchRoutes requires routes to be an object.');
  }

  if (typeof url !== 'string') {
    throw new Error('matchRotes requires url to be a string.');
  }

  const urlWithQueryString = url.split('#')[0];
  const pathname = urlWithQueryString.split('?')[0];

  const match = deepMatchRoutes(routes, pathname, pathname);

  if (match) {
    const queryStringAndHash = url.substring(pathname.length);
    const queryString = queryStringAndHash.split('#')[0];
    const query = queryStringParser.parse(queryString);

    return {
      ...match,
      query
    };
  }

  return null;
};
github kitze / mobx-router / src / route.js View on Github external
goTo(store, paramsArr) {
        const paramsObject = this.getParamsObject(paramsArr);
        const queryParamsObject = queryString.parse(window.location.search);
        store.router.goTo(this, paramsObject, store, queryParamsObject);
    }
}
github dfuse-io / dfuse-eosio / eosq / src / pages / account / tables / account-table-search.tsx View on Github external
initContractTableStore() {
    const parsed = queryString.parse(this.props.location.search)
    contractTableStore.initFromUrlParams(this.props.abiLoader, this.props.accountName, parsed)
  }
github mozilla / addons-code-manager / src / utils.tsx View on Github external
export const createAdjustedQueryString = (
  location: Location,
  newParams: { [key: string]: string | number | boolean | undefined },
) => {
  const query = queryString.parse(location.search);
  return `?${queryString.stringify({ ...query, ...newParams })}`;
};
github ManifoldScholar / manifold / client / src / frontend / containers / ReadingGroup / Members.js View on Github external
static fetchData = (getState, dispatch, location, match) => {
    const params = queryString.parse(location.search);
    const promise = ReadingGroupsMembersContainer.fetchMembers(
      dispatch,
      params.page,
      match
    );
    return Promise.all([promise]);
  };
github mattdesl / codevember / src / 28.js View on Github external
const potCtx = potCanvas.getContext('2d')

const bg = createBackground()
app.scene.add(bg)

let time = 0
app.on('tick', (dt) => {
  time += dt / 1000

  const [ width, height ] = app.shape
  bg.style({
    aspect: width / height
  })
})

const smooth = qs.parse(window.location.search).smooth === 'true'
const geometry = new THREE.TorusKnotGeometry(0.45, 0.25, 128, 256)
const material = createMaterial(!smooth)

const mesh = new THREE.Mesh(geometry, material)
app.scene.add(mesh)

const random = require('unique-random-array')([
  [14.584186, 120.979963],
  [27.175515, 78.04145199999994],
  [10.642237, 122.23580400000003],
  [17.571335, 120.388777],
  [68.196537, 13.531821000000036],
  [0.203972, 37.45297400000004],
  [30.185036, -84.724629],
  [41.403286, 2.1746729999999843],
  [60.070408, 6.542394000000058]

query-string

Parse and stringify URL query strings

MIT
Latest version published 2 months ago

Package Health Score

91 / 100
Full package analysis