From 892200a236d8227c6aec847df33585e83ce26ccf Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 22 Oct 2018 10:10:43 +0200 Subject: [PATCH] fix(cockpit/services/api): make sure query params are serialized correctly In https://github.com/status-im/embark-area-51/commit/9097f31c834b3a25ec73f4caf8c3539502bfc8cd we ensured to send query parameters along with GET requests done by our API service. This resulted in weird behaviour where query parameters have been attached as `params` in a serialized format of our API requests. So instead of sending sth. like: ``` /embark-api?token=foo-bar ``` Requests looked like: ``` /embark-api?params=... ``` This has even been patched accordingly on the server like here https://github.com/status-im/embark-area-51/commit/043697bddccf2b5f47e649eb885b2ece53a1d825, while still being unpatched in other places on the server. It turns out however, that the reason this `params` parameter appears, is that all of our GET requests, already send their payload as `params`. This commit now ensures that GET parameters are sent in the correct format. --- embark-ui/src/services/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embark-ui/src/services/api.js b/embark-ui/src/services/api.js index 50fab190..a750059c 100644 --- a/embark-ui/src/services/api.js +++ b/embark-ui/src/services/api.js @@ -29,7 +29,7 @@ function request(type, path, params = {}) { 'X-Embark-Cnonce': cnonce }, ...(type === 'post' ? { data: params } : {}), - ...(type === 'get' ? { params } : {}) + ...(type === 'get' ? { params: params.params } : {}) } return axios(req)