mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-17 21:53:03 +05:30
правильная true/false сериализация для request
This commit is contained in:
parent
e44360a20b
commit
7e7a31a672
@ -1,8 +1,22 @@
|
|||||||
|
function convertQueryValue(value) {
|
||||||
|
if (typeof value === 'undefined') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value === true) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function buildQuery(data) {
|
function buildQuery(data) {
|
||||||
return Object.keys(data)
|
return Object.keys(data)
|
||||||
.map(
|
.map(
|
||||||
(keyName) =>
|
(keyName) =>
|
||||||
[keyName, typeof data[keyName] === 'undefined' ? '' : data[keyName]]
|
[keyName, convertQueryValue(data[keyName])]
|
||||||
.map(encodeURIComponent)
|
.map(encodeURIComponent)
|
||||||
.join('=')
|
.join('=')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user