pelanggaran.js 721 B

12345678910111213141516171819202122232425262728293031
  1. export const getPelanggaranId = async (id) => {
  2. try {
  3. const data = { id };
  4. const myHeaders = new Headers();
  5. myHeaders.append("Content-Type", "application/json");
  6. const raw = JSON.stringify(data);
  7. const requestOptions = {
  8. method: "POST",
  9. body: raw,
  10. headers: myHeaders,
  11. };
  12. const res = await fetch("http://localhost:5000/pelanggaran", requestOptions);
  13. return await res.json();
  14. } catch (error) {
  15. console.log("error", error);
  16. return false;
  17. }
  18. };
  19. export const getPelanggaran = async () => {
  20. try {
  21. const res = await fetch("http://localhost:5000/pelanggaran");
  22. return await res.json();
  23. } catch (error) {
  24. console.log("error", error);
  25. return false;
  26. }
  27. };