From 7e7a31a672be477c02af612cebaf052fb8b7252a Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sat, 27 Feb 2016 12:58:29 +0200 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20true/false=20=D1=81=D0=B5=D1=80=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/request.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/services/request.js b/src/services/request.js index 511c023..0c17aaa 100644 --- a/src/services/request.js +++ b/src/services/request.js @@ -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) { return Object.keys(data) .map( (keyName) => - [keyName, typeof data[keyName] === 'undefined' ? '' : data[keyName]] + [keyName, convertQueryValue(data[keyName])] .map(encodeURIComponent) .join('=') )