Added services and resolvers for redemptions and related.

This commit is contained in:
Tom
2025-01-13 23:34:10 +00:00
parent fee2c4e12f
commit 7a7fb832a0
9 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import TwitchRedemption from '../models/twitch-redemption';
import { of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class TwitchRedemptionService {
private http = inject(HttpClient);
private twitchRedemptions: TwitchRedemption[] = [];
private loaded = false
fetch(force: boolean = false) {
if (!force && this.loaded)
return of(this.twitchRedemptions);
const $ = this.http.get<TwitchRedemption[]>(environment.API_HOST + '/twitch/redemptions', {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt'),
}
});
$.subscribe(d => {
this.twitchRedemptions = d;
this.loaded = true;
});
return $;
}
}