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

Update QueryApiUtils.js#230

Open
ali-master wants to merge 1 commit intoairbnb:masterfrom
ali-master:patch-1
Open

Update QueryApiUtils.js#230
ali-master wants to merge 1 commit intoairbnb:masterfrom
ali-master:patch-1

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.

1 participant