sanksi.js 849 B

12345678910111213141516171819202122232425262728
  1. import { addLog } from "./log";
  2. export const createSanksi = async ({ number, ptId }, data) => {
  3. try {
  4. const res = await fetch(`http://localhost:5000/sanksi/create?number=${number}&ptId=${ptId}`, {
  5. method: "POST",
  6. body: data,
  7. });
  8. const result = await res.json();
  9. console.log(result);
  10. // addLog({ status: "SUCCESS", action: "CREATE", from: { id: result.added._id, data: "sanksi" }, description: "membuat sanksi" });
  11. return result;
  12. } catch (error) {
  13. console.log("error", error);
  14. addLog({ status: "FAIL", action: "CREATE", from: { data: "sanksi" }, description: error.message || "membuat sanksi" });
  15. return false;
  16. }
  17. };
  18. export const getSanksi = async () => {
  19. try {
  20. const res = await fetch(`http://localhost:5000/sanksi/`);
  21. return await res.json();
  22. } catch (error) {
  23. console.log("error", error);
  24. return false;
  25. }
  26. };