http - TypeError: Cannot read property 'get' of undefined at Object.tokenGetter -


in auth-service.ts

  // success - if there's jwt token in response    let token = response.json() && response.json().token;   if (token) {       // set token property       this.token = token;       this.storage.set('id_token', token);        // store username , jwt token in local storage keep user        // logged in between refreshes       this.storage.set('current_user', json.stringify(response.json()));       this.user = response.json();    // return true indicate successful login       return true;   } 

i store token in storage. when use below code making auth request typeerror: cannot read property 'get' of undefined @ object.tokengetter . , dont know why?

app.module.ts

let storage = new storage(null);  export function getauthhttp(http, storage) {        return new authhttp(new authconfig({        nojwterror:true,        globalheaders: [{ 'accept': 'application/json' }],        tokengetter: (() => storage.get('id_token'))  }), http); } 

i did remember imports , token stored in storage

import { authconfig, authhttp } 'angular2-jwt'; import { http } '@angular/http'; import { storage,ionicstoragemodule }from '@ionic/storage'; 

and declaration in providers

  {provide:authhttp, usefactory:getauthhttp, deps:[http]},      


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -