In my code below I would like would like to finish
this.storage.set ("location", JSON.stringify(lsd_info));
before proceeding to
this.driveTo();
I believe I should be using .then(). What I am wondering is there a simple solution to finish an event before proceeding.
getLoc() {
let a = this.data.lsd;
let b = this.data.sec;
let c = this.data.twp;
let d = this.data.rng;
let e = this.data.mrd;
this.http.get('https://www.reversegeocoder.com/api/v1/PrivateID/lsd/' + a + '-' + b + '-' + c + '-' + d + ' ' + e)
.map(res => res.json())
.subscribe (data => {
let lsd_info = {
latitude: data[0].response.lat,
longitude: data[0].response.lng,
};
let lsd_error = {error: data[0].response.err};
this.ErrorResponse = (JSON.stringify(data[0].response.err));
this.ErrorText = this.ErrorResponse.replace('[','').replace(']','');
this.storage.set ("location", JSON.stringify(lsd_info));
//finish storage.set before proceeding
this.driveTo();
},
err => {
console.log('error');
}
);
}
driveTo() {
this.navCtrl.push(Drive);
}
Or have two functions where on function finished before proceeding
i.e. getLoc() and then driveTo()