You can use API, just put following function into a JS file and import it where you need:


   export function getQuery() {
      let b =
        .map(qStr => qStr.split("="))
        .reduce((acc, inc) => {
          acc[inc[0]] = inc[1];
          return acc;
        }, {});
        return b;

and where you want to use it

import getQuery from './utils/query';
    let q = getQuery();
        let name = q['name']
        let id = q['id']
        let from = q['from']
    //Or directly call it
    let name = getQuery()['name']
    let id = getQuery()['id']
    let from = getQuery()['from']

Related Query

More Query from same tag