getTownFromLocalStorage(){
if (!localStorage.getItem('town')) {
$.getJSON('http://ip-api.com/json', function (data) {
queryParams['lat'] = data.lat;
queryParams['long'] = data.lon;
callApi('towns', queryParams, '').then((res) => {
this.currentCity = res.data.data[0];
localStorage.setItem('town', JSON.stringify(this.currentCity));
})
}.bind(this));
} else {
this.currentCity = JSON.parse(localStorage.getItem('town'));
}
}
getTownFromLocalStorage(town) {
var list = undefined;
if (!localStorage.getItem('town')) {
list = [];
$.getJSON('http://ip-api.com/json', function (data) {
queryParams['lat'] = data.lat;
queryParams['long'] = data.lon;
callApi('towns', queryParams, '').then((res) => {
this.currentCity = res.data.data[0];
})
}.bind(this));
} else {
list = JSON.parse(localStorage.getItem('town'));
console.log(this.currentCity);
this.currentCity = list.name;
}
localStorage.setItem('town', JSON.stringify(town));
}