Skip to content

Instantly share code, notes, and snippets.

@clement-joye
Created May 15, 2021 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clement-joye/7ec89ddf2f34ad10e866d87b62c00eab to your computer and use it in GitHub Desktop.
Save clement-joye/7ec89ddf2f34ad10e866d87b62c00eab to your computer and use it in GitHub Desktop.
getCardData(card: DashboardCard, i: number = 0) {
let resource = card.resources[i];
let variables = card.variables;
let request = prepareRequest(resource, variables, card.pat);
console.log(request.url);
return this.http.get<string>(request.url, { headers: request.httpOptions }).subscribe(
(data: string) => {
postRequest(data, resource, variables);
if(++i < card.resources.length) { this.getCardData(card, i); }
else { card.isLoading = false; }
},
(error: any) => {
console.log(`Backend server returned an error (${error.status} - ${error.message})`);
card.isLoading = false;
card.variables['status'] = 'Unknown';
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment