constructor(
private http: HttpClient,
private snack: MatSnackBar,
) {
}
async loadCached() {
try {
const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32').toPromise()
this.snack.open(`Will be always the same: ${response.random}`, 'OK')
} catch(e) {
this.snack.open(`Sorry, error happened, check the consle for the error`, 'OK')
console.error(e)
}
}
async loadNonCached() {
try {
const response : any = await this.http.get('https://server.patrikx3.com/api/core/util/random/32', {
headers: {
[CachingHeaders.NoCache]: '1'
}
}).toPromise()
this.snack.open(`Truly random data: ${response.random}`, 'OK')
} catch(e) {
this.snack.open(`Sorry, error happened, check the console for the error`, 'OK')
console.error(e)
}
}