Remodelled client authorization

This commit is contained in:
Martin
2021-04-30 15:47:39 +02:00
parent ca1d7fdb7a
commit ff81894215
3 changed files with 19 additions and 7 deletions
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import {AuthService} from '../../services/auth.service';
import {HttpClient, HttpHeaders} from '@angular/common/http';
@Component({
selector: 'app-tweets',
@@ -7,13 +9,24 @@ import { Component, OnInit } from '@angular/core';
})
export class TweetsComponent implements OnInit {
constructor() { }
constructor(private http: HttpClient,
private authService: AuthService) { }
ngOnInit(): void {
}
loadMore() {
console.log('TODO: Implement');
}
const headerDict = {
'Authorization': 'Bearer ' + this.authService.getToken(),
};
return this.http.get('http://localhost:8000/api/login',
{
headers: new HttpHeaders(headerDict),
observe: 'response',
})
.subscribe(data => { console.log(data); alert('Returned with code: ' + data['status']); });
}
}
}