Skip to content

Instantly share code, notes, and snippets.

@rdlabo
Created August 26, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdlabo/d93361c8b06df0fbde26df1c91f9fa01 to your computer and use it in GitHub Desktop.
Save rdlabo/d93361c8b06df0fbde26df1c91f9fa01 to your computer and use it in GitHub Desktop.
Ionic Storage & HTTP
@Injectable({
providedIn: 'root',
})
export class AuthService {
constructor(
public http: HttpClient,
public storage: Storage,
) {}
async getState() {
const token = await this.storage.get('token');
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': token
})
};
return this.http.get('functions/auth', httpOptions);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment