Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Update QueryApiUtils.js #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ali-master
Copy link

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 &.

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 **&**.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant