Issue with local storage element in ios http post


#1

I have issue with sending local storage element in http post request. it works with android and website but not in ios. http request is being executed before getting local storage element in ios . if i send manually it works in ios. I have used async and await but i don’t konow why this problem in ios only. here is two ways what i did. i know this is very strange issue.

async rpichart(): Promise<rpidataList[]> {
    const username = await this.storage.get('name');
    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
    var options = new RequestOptions({ headers: headers });
    let response = await this.http.post('http://node.services.com:3084/api/rpichart', JSON.stringify({ username: username }), options).toPromise();
    return response.json() as rpidataList[]; 
  }



rpichart() {
    return this.storage.get('name').then((username) => {
      let headers = new Headers();
      headers.append('Content-Type', 'application/json');
      var options = new RequestOptions({ headers: headers });
      return this.http.post('http://node.services.com:3084/api/rpichart/', JSON.stringify({ username: username }), options).map(res => res.json()).toPromise()
    });
  }