Skip to content

Commit f4d4623

Browse files
fix requests params
1 parent c59fca4 commit f4d4623

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ui/src/api/CWaterPumpAPIImpl.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ class CWaterPumpAPIImpl {
1313

1414
async start(runTimeMs) {
1515
const { response: { data }, requestTime } = await this._execute(
16-
async () => await this._client.get('/pour_tea', { milliseconds: runTimeMs })
16+
async () => await this._client.get('/pour_tea', { params: { milliseconds: runTimeMs } })
1717
);
1818
return this.preprocessResponse({ response: data, requestTime });
1919
}
2020

2121
async stop() {
2222
const { response: { data }, requestTime } = await this._execute(
23-
async () => await this._client.get('/stop', {})
23+
async () => await this._client.get('/stop', { params: {} })
2424
);
2525
return this.preprocessResponse({ response: data, requestTime });
2626
}
2727

2828
async status() {
2929
const { response: { data }, requestTime } = await this._execute(
30-
async () => await this._client.get('/status', {})
30+
async () => await this._client.get('/status', { params: {} })
3131
);
3232
return this.preprocessResponse({ response: data, requestTime });
3333
}
@@ -36,7 +36,6 @@ class CWaterPumpAPIImpl {
3636
preprocessResponse({ response, requestTime }) {
3737
if(null == response) return null;
3838
if('error' in response) {
39-
// TODO: handle errors in slice/SystemStatus.js
4039
throw new Error(response.error);
4140
}
4241
// make a deep copy of response

ui/src/api/CWaterPumpAPIImpl.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ describe('CWaterPumpAPIImpl', () => {
1919
await expect(apiCall(api)).rejects.toThrow(errorMessage);
2020
}
2121

22-
async function shouldBeCalledWith(apiCall, url, params=null) {
22+
async function shouldBeCalledWith(apiCall, url, params) {
2323
const mockClient = { get: jest.fn() };
2424
mockClient.get.mockResolvedValue({ data: DUMMY_STATUS });
2525

2626
const api = new CWaterPumpAPIImpl({ client: mockClient });
2727
await apiCall(api);
2828

29-
expect(mockClient.get).toHaveBeenCalledWith(url, params);
29+
expect(mockClient.get).toHaveBeenCalledWith(url, { params });
3030
}
3131

3232
async function shouldRethrowError(apiCall) {

0 commit comments

Comments
 (0)