Angular2 synchronous promise

In Ionic 2 the get function for accessing localStorage returns a promise. The problem with the below code is that the headers object gets returned before it has been appended with the Authorization key. How could I modify the below function such that the headers object is returned only after the promise is resolved.

private _createAuthHeaders(): Headers {
    let headers = new Headers({
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      headers.append('Authorization', res);
    }, err=>{
      headers.append('Authorization', '');
    return headers;

Leave a Reply

Notify of