When the interface is connected to the backend, the backend cannot receive the parameters, or the parameters have problems, and the parameters need to be serialized

  • NPM install qs;
  • Import qs from ‘qs’;
  • Let conditon = qs.stringify(data);

Among them:

Qs.parse () parses the URL into an object;

Such as:

let url = 'method=query_sql_dataset_data&projectId=85&appToken=7d22e38e-5717-11e7-907b-a6006ad3dba0';
Qs.parse(url);
console.log(Qs.parse(url));
Copy the code

Qs.stringify () serializes the object into a URL, concatenated with &

Such as:

let obj= {
     method: "query_sql_dataset_data",
     projectId: "85",
     appToken: "7d22e38e-5717-11e7-907b-a6006ad3dba0",
     datasetId: " 12564701"
   };
Qs.stringify(obj);
console.log(Qs.stringify(obj));
Copy the code