pelanggaran.js 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // import { API_URL } from "@/env";
  2. import axios from "../config/axios";
  3. export const getPelanggaranId = async (id) => {
  4. try {
  5. const data = { id };
  6. const myHeaders = new Headers();
  7. myHeaders.append("Content-Type", "application/json");
  8. const raw = JSON.stringify(data);
  9. const requestOptions = {
  10. method: "POST",
  11. body: raw,
  12. headers: myHeaders,
  13. };
  14. const res = await fetch(API_URL + "/pelanggaran", requestOptions);
  15. return await res.json();
  16. } catch (error) {
  17. console.log("error", error);
  18. return false;
  19. }
  20. };
  21. export const getPelanggaran = async (token) => {
  22. try {
  23. const res = await axios.get("/pelanggaran", {
  24. headers: {
  25. Authorization: token,
  26. },
  27. });
  28. return await res.data;
  29. } catch (error) {
  30. console.log("error", error);
  31. return false;
  32. }
  33. };
  34. export const getPelanggaranPublic = async (token) => {
  35. try {
  36. const res = await axios.get("/public/pelanggaran");
  37. return await res.data;
  38. } catch (error) {
  39. console.log("error", error);
  40. return false;
  41. }
  42. };