From b015f7b61a2054a878e6e9542cfbd79192d37875 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 12 Feb 2025 13:44:56 -0800 Subject: [PATCH] destructure var, build form to update monitor --- Client/src/Utils/NetworkService.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Client/src/Utils/NetworkService.js b/Client/src/Utils/NetworkService.js index 515ae5930..0a7900e1c 100644 --- a/Client/src/Utils/NetworkService.js +++ b/Client/src/Utils/NetworkService.js @@ -99,9 +99,11 @@ class NetworkService { * @returns {Promise} The response from the axios POST request. */ async createMonitor(config) { - return this.axiosInstance.post(`/monitors`, config.monitor, { + const { authToken, monitor } = config; + + return this.axiosInstance.post(`/monitors`, monitor, { headers: { - Authorization: `Bearer ${config.authToken}`, + Authorization: `Bearer ${authToken}`, "Content-Type": "application/json", }, }); @@ -284,9 +286,16 @@ class NetworkService { * @returns {Promise} The response from the axios PUT request. */ async updateMonitor(config) { - return this.axiosInstance.put(`/monitors/${config.monitorId}`, config.updatedFields, { + const { authToken, monitorId, monitor } = config; + const updatedFields = { + name: monitor.name, + description: monitor.description, + interval: monitor.interval, + notifications: monitor.notifications, + }; + return this.axiosInstance.put(`/monitors/${monitorId}`, updatedFields, { headers: { - Authorization: `Bearer ${config.authToken}`, + Authorization: `Bearer ${authToken}`, "Content-Type": "application/json", }, });