diff --git a/app/Http/Controllers/GeoIPController.php b/app/Http/Controllers/GeoIPController.php index b47772e..62814df 100644 --- a/app/Http/Controllers/GeoIPController.php +++ b/app/Http/Controllers/GeoIPController.php @@ -9,6 +9,6 @@ class GeoIPController extends Controller { public function index(Request $request, $ip = null) { - return (array)geoip($ip = null)->getLocation(); + return geoip($ip)->getLocation()->toArray(); } } diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue index 3484929..630e5ff 100644 --- a/resources/js/Pages/IkeaRoot.vue +++ b/resources/js/Pages/IkeaRoot.vue @@ -245,12 +245,14 @@ const fetch_rates = async () => { const fetch_ccodes = async () => { try { + const response2 = await axios.get(route('geo.ip.get')); + geoip.value = response2.data; + const response = await axios.get(route('ccountry.codes')) ccodes.value = response.data; ccodes.value = Object.entries(ccodes.value).map(([k, v]) => { if (v !== null) return { "country": k, "code": v } }).filter(n => n); console.log("ccodes=", ccodes.value); - const response2 = await axios.get(route('geo.ip.get')); - geoip.value = response2.data; + } catch (e) { const response = await Swal.fire({ title: __('are you want to try again') + '?', @@ -354,6 +356,7 @@ const submit = () => { watch(ccodes, (codes) => { console.log('NNN=',codes); + console.log('IP=',geoip.value); codes.forEach((c) => { if (c.code == geoip.value.iso_code) form.country = c; }); console.log(form.country); })