Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70442

Ionic 3: Ionic Storage with Observables

$
0
0

@maxkoch wrote:

Hey Ionites!

I have CustomerPage, CustomerService and AuthService.

In need to pass an access_token from AuthService to CustomerService for http-get request.
AuthService and CustomerService are not working(see comments).
Please help me :slight_smile:

CustomerPage:

this.customerService.getCustomersDashboard()
      .subscribe(....)

CustomerService:

getCustomersDashboard(): Observable<any> {
      var url = "......";
    let authHeader = this.authservice.getAuthHeaders();  // HttpHeader with access_token

    return this.http.get(url, { headers: authHeader }).pipe(
      map((resp: Response) => {
        let response = this.extractData(resp);
        return response;
      }));

AuthService:
** is not working !!!**

 getAuthHeaders(){
    const authtoken = Observable.fromPromise(this.storage.get(`access_token`));
   
    return new HttpHeaders({ 'authorization': authtoken });  // => **not working**
  }

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70442

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>