Fetch json data based on geolocation


#1

I m using Ionic 3
I have JSON data coming from server, and I want to fetch data country based on geolocation country

I mean json country must same with geolocation country

[
{
id: 301,
ref: 169,
img: "image1.jpg",
title: "lorem epsum",
country: "usa"
},
{
id: 302,
ref: 168,
img: "image2.jpg",
title: "lorem ipsum",
country: "germany",

},

I need methode to fetch it by name country such as json file there ?? is it possible??


#2

I understand that you want to search in the data by a country name ?

CountriesData = [
{
id: 301,
ref: 169,
img: "image1.jpg",
title: "lorem epsum",
country: "usa"
},
{
id: 302,
ref: 168,
img: "image2.jpg",
title: "lorem ipsum",
country: "germany",

}
]

germany = CountriesData.filter( (data) => {
return data.country == "germany";
});

For more


#3

yes exactly

but I need fetch data according to geolocation phone ok

here is Cordova plugin but i dont know how to use