data dari api

This commit is contained in:
2025-06-04 08:54:26 +07:00
parent 49770ba9f0
commit 3b288fd861
13 changed files with 385 additions and 36 deletions

21
stores/api/menu.ts Normal file
View File

@@ -0,0 +1,21 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useMenu = defineStore("menu", () => {
const listMenu = ref<any>([]);
const getMenu = async () => {
// await $fetch("http://10.10.150.131:8080/api/menu/getlist", {
await $fetch("/api/menu/listMenu", {
// mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
method:"GET",
})
.then((res) => {
listMenu.value = res
console.log(listMenu.value);
});
// return listMenu;
};
return { getMenu,listMenu };
});

24
stores/api/roleMenu.ts Normal file
View File

@@ -0,0 +1,24 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useRoleMode = defineStore("roleMode", () => {
const typeUser = ref<any>([]);
const roleMenuById = ref<any>([]);
const getRoleMenuById = async (body: Record<string, any>) => {
typeUser.value = body;
// console.log(typeUser.value);
// await $fetch("http://10.10.150.131:8080/api/menu/getlist", {
await $fetch(`/api/roleMenu/roleMenu`, {
// mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify(body),
}).then((res) => {
roleMenuById.value = res;
// console.log(roleMenuById.value);
});
// return roleMenuById;
};
return { getRoleMenuById, roleMenuById, typeUser };
});

View File

@@ -1,22 +1,23 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useTypeUser = defineStore("typeUser", () => {
const data = ref<any>([]);
const getTypeUser = async (body: Record<string, any>) => {
const a = await $fetch("http://10.10.150.131:8080/api/menu/getlist", {
mode: "no-cors",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
const listTypeUser = ref<any>([]);
const getTypeUser = async () => {
// await $fetch("http://10.10.150.131:8080/api/menu/type", {
await $fetch("/api/typeUser/listTypeUser", {
// mode: 'no-cors',
// headers: {
// 'Access-Control-Allow-Origin': '*',
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
method:"GET",
})
// .then((res) => {
// data.value = res
// console.log(data.value);
// });
// return data;
console.log(a);
.then((res) => {
listTypeUser.value = res
// console.log(listTypeUser.value);
});
// return listTypeUser;
};
return { getTypeUser,data };
return { getTypeUser,listTypeUser };
});