refactor(stores): added in axios

This commit is contained in:
2025-03-19 17:12:27 -05:00
parent 1cd1d3a3e9
commit 3b8f18093e
3 changed files with 13 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import {Modules} from "@/types/modules";
import axios from "axios";
import {create} from "zustand";
interface SettingState {
@@ -17,14 +18,8 @@ export const useModuleStore = create<SettingState>()((set) => ({
fetchModules: async () => {
try {
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
const response = await fetch(`/api/server/modules`, {
method: "GET",
headers: {
"Content-Type": "application/json",
// You can add other headers here if necessary
},
});
const data: FetchModulesResponse = await response.json();
const response = await axios.get(`/api/server/modules`, {});
const data: FetchModulesResponse = response.data; //await response.json();
//console.log(data);
set({modules: data.data});
} catch (error) {