【发布时间】:2019-10-15 17:23:00
【问题描述】:
我从用户输入中获取设置并将其存储在本地存储中。我在 API 调用中使用这些数据。
userlocation;
userservice ;
usercategory ;
constructor(public http: HttpClient, public storage : Storage) { }
getListings(){
this.storage.get('area').then((userlocation) => {
this.userlocation = userlocation;
console.log(this.userlocation)
});
this.storage.get('ser').then((userservice) => {
this.userservice = userservice;
console.log(this.userlocation)
});
return this.http.get(this.api_url+"?location="+ this.userlocation+
"&ser= " + this.userservice)
}
api调用在localstorage获取数据之前发生的问题。 如何让 API 调用等待本地存储
【问题讨论】:
-
当你从 localStorage 获取不同的值时,为什么要使用相同的变量名??
-
是的,这是我的问题,但我认为这不能解决问题
标签: api ionic-framework angular6 local-storage ionic4