How to use the qs.parse 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 hungdev / react-native-instagram-login / Instagram.js View on Github external
async _onNavigationStateChange(webViewState) {
    const { url } = webViewState
    const { key } = this.state
    if (webViewState.title === 'Instagram' && webViewState.url === 'https://www.instagram.com/') {
      this.setState({ key: key + 1 })
    }
    if (url && url.startsWith(this.props.redirectUrl)) {
      const match = url.match(/(#|\?)(.*)/)
      const results = qs.parse(match[2])
      this.hide()
      if (results.access_token) {
        // Keeping this to keep it backwards compatible, but also returning raw results to account for future changes.
        this.props.onLoginSuccess(results.access_token, results)
      } else if (results.code) {

        //Fetching to get token with appId, appSecret and code
        let { code } = results
        code = code.split('#_').join('')
        const { appId, appSecret, redirectUrl, scopes } = this.props
        let headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
        let http = axios.create({ baseURL: 'https://api.instagram.com/oauth/access_token',  headers: headers  })
        let form = new FormData();
        form.append( 'app_id', appId );
        form.append( 'app_secret', appSecret );
        form.append( 'grant_type', 'authorization_code' );
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.admin.feature / src / main / resources / admin / source / src / App.jsx View on Github external
handleEnvironmentQueryParam() {
        let queryString = this.props.location.search;
        queryString = queryString.replace(/^\?/, '');
        /* With QS version up we can directly use {ignoreQueryPrefix: true} option */
        const queryParams = qs.parse(queryString);
        const environmentName = queryParams.environment;

        if (!environmentName || this.environmentName === environmentName) {
            // no environment query param or the same environment
            return;
        }

        const environmentId = Utils.getEnvironmentID(this.state.environments, environmentName);
        if (environmentId === -1) {
            console.error('Invalid environment name in environment query parameter.');
            return;
        }

        const environment = this.state.environments[environmentId];
        Utils.setEnvironment(environment);
        this.environmentName = environmentName;
github expo / expo / packages / expo / src / AuthSession.ts View on Github external
let parts = url.split('#');
  let hash = parts[1];
  let partsWithoutHash = parts[0].split('?');
  let queryString = partsWithoutHash[partsWithoutHash.length - 1];

  // Get query string (?hello=world)
  let parsedSearch = qs.parse(queryString);

  // Pull errorCode off of params
  let { errorCode } = parsedSearch;
  delete parsedSearch.errorCode;

  // Get hash (#abc=example)
  let parsedHash = {};
  if (parts[1]) {
    parsedHash = qs.parse(hash);
  }

  // Merge search and hash
  let params = {
    ...parsedSearch,
    ...parsedHash,
  };

  return {
    errorCode,
    params,
  };
}
github unihooks / unihooks / src / useQueryParam.js View on Github external
Promise.resolve().then(() => {
      let search = window.location.search.slice(1)
      let params = qs.parse(search)
      Object.assign(params, plannedParams)

      params = sorted(params)
      let str = qs.stringify(params, { encode: false })

      // ignore unchanged transition
      if (str === search) return

      window.history.replaceState(null, '', str ? '?' + str : window.location.href.split('?')[0])
      plannedTimeout = null
      plannedParams = {}
    })
  }
github greper / d2-crud-plus / packages / d2-crud-plus-example / src / mock / d2-mock / index.js View on Github external
const wired = ({ url, type, body }) => ({
  method: type,
  params: qs.parse(url.split('?').length > 1 ? url.split('?')[1] : ''),
  body: JSON.parse(body),
  url: qs.parse(url.split('?')[0]),
  ...CustomExtends
})
github oklai / koala / src / app / node_modules / less / node_modules / request / index.js View on Github external
Request.prototype.oauth = function (_oauth) {
  var form
  if (this.headers['content-type'] &&
      this.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
        'application/x-www-form-urlencoded'
     ) {
    form = qs.parse(this.body)
  }
  if (this.uri.query) {
    form = qs.parse(this.uri.query)
  }
  if (!form) form = {}
  var oa = {}
  for (var i in form) oa[i] = form[i]
  for (var i in _oauth) oa['oauth_'+i] = _oauth[i]
  if (!oa.oauth_version) oa.oauth_version = '1.0'
  if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( Date.now() / 1000 ).toString()
  if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')

  oa.oauth_signature_method = 'HMAC-SHA1'

  var consumer_secret = oa.oauth_consumer_secret
  delete oa.oauth_consumer_secret
  var token_secret = oa.oauth_token_secret
  delete oa.oauth_token_secret
  var timestamp = oa.oauth_timestamp
github mirumee / saleor-dashboard / src / translations / index.tsx View on Github external
const TranslationsEntities: React.FC = ({
  location,
  match
}) => {
  const qs = parseQs(location.search.substr(1));

  return (
    
  );
};
type TranslationsEntityRouteProps = RouteComponentProps<{
github goodjoblife / GoodJobShare / src / components / ShareExperience / TimeSalaryForm / index.js View on Github external
const getDefaultFormFromLocation = location => {
  const companyName = qs.parse(location.search, { ignoreQueryPrefix: true })
    .companyName;
  if (companyName) {
    return {
      ...defaultForm,
      company: companyName,
    };
  }
  return null;
};
github fluid-notion / fluid-outliner / core / views / models / RouteViewModel.ts View on Github external
export const parseQuery = (rawQuery = currentRawQuery()) => qs.parse(rawQuery)

qs

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

BSD-3-Clause
Latest version published 11 days ago

Package Health Score

94 / 100
Full package analysis