log.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import axios from "@/config/axios";
  2. import axios2 from "axios";
  3. export const getLog = async (token, laporan_id) => {
  4. try {
  5. let url = `/pemantauan/${laporan_id}`;
  6. const res = await axios.get(url, {
  7. headers: {
  8. Authorization: token,
  9. },
  10. });
  11. return res.data;
  12. } catch (error) {
  13. console.log("error", error);
  14. return false;
  15. }
  16. };
  17. export const getLogPT = async (token) => {
  18. try {
  19. let url = `/pemantauan/pt`;
  20. const res = await axios.get(url, {
  21. headers: {
  22. Authorization: token,
  23. },
  24. });
  25. return res.data;
  26. } catch (error) {
  27. console.log("error", error);
  28. return false;
  29. }
  30. };
  31. export const getLogPublic = async ({ no_hp, no_laporan }) => {
  32. try {
  33. const res = await axios.get(`/public/pemantauan?no_hp=${no_hp}&no_laporan=${no_laporan}`);
  34. return res.data;
  35. } catch (error) {
  36. console.log("error", error);
  37. return false;
  38. }
  39. };
  40. export const createLog = async (token, data) => {
  41. try {
  42. const jsonip = await axios2.get("https://jsonip.com", { mode: "cors" });
  43. const res = await axios.post("/log", { os: navigator.userAgentData.platform, ipv4: jsonip.data.ip, ...data }, { headers: { Authorization: token } });
  44. return res.data;
  45. } catch (error) {
  46. console.log("error", error);
  47. return false;
  48. }
  49. };
  50. export const getLog2 = async (token) => {
  51. try {
  52. const res = await axios.get(`/log`, { headers: { Authorization: token } });
  53. return res.data;
  54. } catch (error) {
  55. console.log("error", error);
  56. return false;
  57. }
  58. };