I am using Wikipedia's api and the response looks like this:
{
'query': {
'pages': {
212187: {
'extract': value;
}
}
}
}
I am trying to get the extract value. However, when I cannot get past the 212187 because it is a number that will change with each call I make. This is not allowing me to accurately model out the response object. The current model I have is undefined at the 212187 level and blocking me from getting to extract.
How can I accomplish this? Any help/suggestions/tips would be appreciated.
UPDATE I have an interface that matches the response structure exactly except the 212187 I have as number (assumed that would be wrong). My Request looks like:
fetchDescriptionWiki(qSearch: string) {
const params: URLSearchParams = new URLSearchParams();
params.set('origin', '*');
params.set('format', 'json');
params.set('action', 'query');
params.set('prop', 'extracts');
params.set('exintro', '');
params.set('explaintext', '');
params.set('indexpageids', '');
params.set('titles', qSearch);
const options = new RequestOptions({
search: params
});
return this.http.get(this.pendingCardsDescriptionWikiUrl, options)
.map(this.extractApiData);
}
extractApiData:
private extractApiData(res: Response) {
const body = res.json();
return body || [];
}
My component.ts function looks like:
getDescription() {
this.pendingCardService.fetchDescriptionWiki('SomeStringValue')
.subscribe(data => {
this.wikiResult = data;
});
}
This is where I got stuck with being able to dig into the response and get the value of extract.
{ [key: number]: Extract }.