refactor(stores): added in axios
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user