Commit 480f522f authored by VladikB's avatar VladikB

Alles funktioniert

parent 91104584
import { TestBed } from '@angular/core/testing';
import { BonusTokenService } from './bonus-token.service';
import {BonusTokenMockService} from './bonus-token.mock.service';
describe('BonusTokenService', () => {
let service: BonusTokenService;
......@@ -10,8 +9,7 @@ describe('BonusTokenService', () => {
TestBed.configureTestingModule({
providers: [
{
provide: BonusTokenService,
useClass: BonusTokenMockService
provide: BonusTokenService
}
]
});
......
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {UserService} from '../user.service';
import {DefaultSettings} from '../../../lib/default.settings';
@Injectable({
providedIn: 'root'
})
export class BonusTokenService {
public bonusToken: string;
private configUrl: string;
constructor(private http: HttpClient, private userService: UserService) {
constructor(private http: HttpClient) {
this.bonusToken = 'afsml8';
http.request('GET', `${DefaultSettings.httpApiEndpoint}/member/bonustoken`, {
headers: {authorization: this.userService.staticLoginToken},
observe: 'body',
responseType: 'text',
withCredentials: true
}).subscribe(
nextResult => {
this.bonusToken = nextResult;
},
err => console.error('Observer got an error: ' + err),
() => console.log('Observer got a complete notification')
);
}
public getToken(): string {
return this.bonusToken;
this.configUrl = 'https://staging.arsnova.click/backend/api/v1/member/token';
this.http.get(this.configUrl).subscribe(data => {
this.bonusToken += data['status'];
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment