From 31c28bd17777db5a5ddd14939439cec286f83301 Mon Sep 17 00:00:00 2001 From: Joaquim Rocha Date: Thu, 9 Jun 2022 14:52:13 +0100 Subject: [PATCH] frontend: Prevent sending an empty version when fetching instances Sending an empty version is not allowed in the current API. That should be ideally prevented in the backend, but until then, this patch removes an empty version from the query params in the respective API call. --- frontend/src/api/API.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/api/API.ts b/frontend/src/api/API.ts index 02fee216a..3195b4f7d 100644 --- a/frontend/src/api/API.ts +++ b/frontend/src/api/API.ts @@ -195,12 +195,19 @@ export default class API { static getInstances( applicationID: string, groupID: string, - queryOptions = {} + queryOptions: { + [key: string]: any; + } = {} ): Promise { let url = BASE_URL + '/apps/' + applicationID + '/groups/' + groupID + '/instances'; if (!_.isEmpty(queryOptions)) { - url += '?' + queryString.stringify(queryOptions); + let sanitizedOptions = queryOptions; + const { version, ...otherOptions } = queryOptions; + if (!version) { + sanitizedOptions = otherOptions; + } + url += '?' + queryString.stringify(sanitizedOptions); } return API.getJSON(url);