airbnb / airpal

Web UI for PrestoDB.
http://airbnb.github.io/airpal
Apache License 2.0
2.76k stars 456 forks source link

Update QueryApiUtils.js #230

Open ali-master opened 6 years ago

ali-master commented 6 years ago

Hi,

 let formData = Object.keys(data).reduce((encoded, key) => {
      const encKey = encodeURIComponent(key);
      const encData = encodeURIComponent(data[key]);
      return `${encoded}&${encKey}=${encData}`
}, '');

Then:

let data = {a: "1", b: "2"} // result of formData: &a=1&b=2

So we should be replaced first & with an empty string, while we can create an array of keys and join them together with &.