diff --git a/utils/callDeviceGroupApi.tsx b/utils/callDeviceGroupApi.tsx index bdf6a52..d7d2f1b 100644 --- a/utils/callDeviceGroupApi.tsx +++ b/utils/callDeviceGroupApi.tsx @@ -4,13 +4,12 @@ function isValidDeviceGroupName(name: string): boolean { export const apiGetAllDeviceGroups = async () => { try { - const response = await fetch(`/config/v1/device-group/`, { + return await fetch(`/config/v1/device-group/`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; @@ -22,13 +21,12 @@ export const apiGetDeviceGroup = async (name: string) => { throw new Error(`Error getting device group: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/device-group/${name}`, { + return await fetch(`/config/v1/device-group/${name}`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; @@ -40,14 +38,13 @@ export const apiPostDeviceGroup = async (name: string, deviceGroupData: any) => throw new Error(`Error updating device group: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/device-group/${name}`, { + return await fetch(`/config/v1/device-group/${name}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(deviceGroupData), }); - return response } catch (error) { console.error(error); throw error; @@ -59,13 +56,12 @@ export const apiDeleteDeviceGroup = async (name: string) => { throw new Error(`Error deleting device group: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/device-group/${name}`, { + return await fetch(`/config/v1/device-group/${name}`, { method: "DELETE", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; diff --git a/utils/callNetworkSliceApi.tsx b/utils/callNetworkSliceApi.tsx index fc88463..de5e399 100644 --- a/utils/callNetworkSliceApi.tsx +++ b/utils/callNetworkSliceApi.tsx @@ -4,13 +4,12 @@ function isValidNetworkSliceName(name: string): boolean { export const apiGetAllNetworkSlices = async () => { try { - const networkSlicesResponse = await fetch(`/config/v1/network-slice`, { + return await fetch(`/config/v1/network-slice`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return networkSlicesResponse } catch (error) { console.error(error); throw error; @@ -22,13 +21,12 @@ export const apiGetNetworkSlice = async (name: string) => { throw new Error(`Error getting network slice: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/network-slice/${name}`, { + return await fetch(`/config/v1/network-slice/${name}`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; @@ -40,14 +38,13 @@ export const apiPostNetworkSlice = async (name: string, sliceData: any) => { throw new Error(`Error updating network slice: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/network-slice/${name}`, { + return await fetch(`/config/v1/network-slice/${name}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(sliceData), }); - return response } catch (error) { console.error(error); throw error; @@ -59,13 +56,12 @@ export const apiDeleteNetworkSlice = async (name: string) => { throw new Error(`Error deleting network slice: Invalid name provided ${name}.`); } try { - const response = await fetch(`/config/v1/network-slice/${name}`, { + return await fetch(`/config/v1/network-slice/${name}`, { method: "DELETE", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; diff --git a/utils/callSubscriberApi.tsx b/utils/callSubscriberApi.tsx index 3dea738..5112aff 100644 --- a/utils/callSubscriberApi.tsx +++ b/utils/callSubscriberApi.tsx @@ -4,13 +4,12 @@ function isValidSubscriberName(name: string): boolean { export const apiGetAllSubscribers = async () => { try { - var response = await fetch(`/api/subscriber`, { + return await fetch(`/api/subscriber`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; @@ -22,13 +21,12 @@ export const apiGetSubscriber = async (imsi: string) => { throw new Error(`Error getting subscriber: Invalid name provided ${imsi}.`); } try { - const response = await fetch(`/api/subscriber/imsi-${imsi}`, { + return await fetch(`/api/subscriber/imsi-${imsi}`, { method: "GET", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; @@ -40,14 +38,13 @@ export const apiPostSubscriber = async (imsi: string, subscriberData: any) => { throw new Error(`Error updating subscriber: Invalid name provided ${imsi}.`); } try { - const response = await fetch(`/api/subscriber/imsi-${imsi}`, { + return await fetch(`/api/subscriber/imsi-${imsi}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(subscriberData), }); - return response } catch (error) { console.error(error); throw error; @@ -59,13 +56,12 @@ export const apiDeleteSubscriber = async (imsi: string) => { throw new Error(`Error deleting subscriber: Invalid name provided ${imsi}.`); } try { - const response = await fetch(`/api/subscriber/imsi-${imsi}`, { + return await fetch(`/api/subscriber/imsi-${imsi}`, { method: "DELETE", headers: { "Content-Type": "application/json", }, }); - return response } catch (error) { console.error(error); throw error; diff --git a/utils/getNetworkSlice.tsx b/utils/getNetworkSlice.tsx deleted file mode 100644 index 881527e..0000000 --- a/utils/getNetworkSlice.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { NetworkSlice } from "@/components/types"; -import { apiGetNetworkSlice } from "@/utils/callNetworkSliceApi"; - -export const getNetworkSlice = async (sliceName: string): Promise => { - try { - const response = await apiGetNetworkSlice(sliceName); - if (!response.ok) { - throw new Error("Failed to fetch network slice"); - } - const slice = await response.json(); - return slice; - } catch (error) { - console.error(error); - throw error; - } -};