Merge pull request #29 from WebEngineering2/frontend

Frontend
This commit is contained in:
kevinpauer
2022-03-28 18:07:35 +02:00
committed by GitHub
13 changed files with 144 additions and 50 deletions

View File

@@ -11,18 +11,19 @@ const httpOptions = {
})
export class AuthService {
constructor(private http: HttpClient) {}
login(username: string, password: string): Observable<any> {
login(email: string, password: string): Observable<any> {
return this.http.post(AUTH_API + '/login', {
username,
email,
password,
});
}
register(username: string, password: string): Observable<any> {
register(email: string, username: string, password: string): Observable<any> {
return this.http.post(
AUTH_API + '/register',
{
username,
email,
password,
username,
},
httpOptions
);

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { Injectable, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { delay, Observable } from 'rxjs';
import { TokenStorageService } from './token.service';
const API_URL = 'https://aktienbot.flokaiser.com/api/';
@Injectable({
@@ -12,26 +12,32 @@ export class DataService {
private tokenStorage: TokenStorageService
) {}
headers = new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
});
async getStockData() {
await this.http
.get(API_URL + 'portfolio', {
headers: this.headers,
responseType: 'text',
})
.subscribe((data) => {
console.log(data);
return data;
});
public getStockData(): Observable<any> {
return this.http.get(API_URL + 'portfolio', {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
});
}
getKeywords(): Observable<any> {
public getTransactionData(): Observable<any> {
return this.http.get(API_URL + 'transactions', {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
});
}
public getKeywords(): Observable<any> {
return this.http.get(API_URL + 'keywords', {
headers: this.headers,
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
}),
responseType: 'text',
});
}