QS Stringify with Vue Router

Viewed 3698

Im having issue implementing the qs package from https://github.com/ljharb/qs in VueJS.

let test = qs.stringify({ test: ['a','b','c'] });

This gives me a url such as https://example.dev/#/search?test[0]=a&test[1]=b&test[2]=c

When I paste this URL into the address bar it gets changed to https://example.dev/#/search?test%5B0%5D=a&test%5B1%5D=b&test%5B2%5D=c

Below is how I am handling the parsing of the URL

let routes = [
  {
    path: '/',
    component: require('./pages/search'), 
    parseQuery: function (queryString) {
      return qs.parse(queryString);
    }
  },
];

But everything returns as undefined

console.log('this.$route.query.test = '+this.$route.query.test);
//this.$route.query.test = undefined

I've tried it with the { encode: false } flag on and off, but I just can't get past this issue. What am I doing wrong?

0 Answers
Related