I'm trying to use the querystring package in an Aurelia application but getting Cannot read property 'stringify' of undefined
error in the browser console.
These are the steps I took:
jspm install querystring
import {querystring} from 'querystring'
into the Aurelia modelUse in my model like so:
import {querystring} from 'querystring';
export class App {
criteria_words;
criteria_location;
constructor() {
}
submit() {
console.log(querystring.stringify(this));
}
}
What step am I missing?
First, jspm install querystring
will not install the library that you have mentioned. The command that you should run is this:
jspm install npm:qs
Then, you can import and use it like this:
import querystring from 'qs';
// call querystring.stringify(someObject);
Or
import {stringify} from 'qs';
// call stringify(someObject);