Selaa lähdekoodia

fixing log fe

yazid138 3 vuotta sitten
vanhempi
commit
319c28b8d3
1 muutettua tiedostoa jossa 9 lisäystä ja 3 poistoa
  1. 9 3
      actions/log.js

+ 9 - 3
actions/log.js

@@ -1,6 +1,6 @@
 import { get } from "../config/request";
 import axios from "@/config/axios";
-import ip from "ip";
+import axios2 from "axios";
 import osValue from "../utils/osValue";
 
 export const getLog = async (token, laporan_id) => {
@@ -44,8 +44,14 @@ export const getLogPublic = async ({ no_hp, no_laporan }) => {
 };
 
 export const createLog = async (token, data) => {
-	const res = await axios.post("/log", { os: osValue(), ipv4: ip.address("public", "ipv4"), ...data }, { headers: { Authorization: token } });
-	return res.data;
+	try {
+		const jsonip = await axios2.get("https://jsonip.com", { mode: "cors" });
+		const res = await axios.post("/log", { os: window.navigator.platform, ipv4: jsonip.data.ip, ...data }, { headers: { Authorization: token } });
+		return res.data;
+	} catch (error) {
+		console.log("error", error);
+		return false;
+	}
 };
 
 export const getLogAdmin = async (token) => {