I believe that I am getting an object back from the wikimedia API, however can't figure out how I can parse it to display.
//app.component.ts
import { Component } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Post } from './post';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Wiki Search';
// readonly ROOT_URL = 'https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=japan&origin=*&format=json';
readonly ROOT_URL = 'https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=Harry Potter&origin=*&callback=JSON_CALLBACK';
// https://en.wikipedia.org/w/api.php?action=query&format=json&gsrlimit=15&generator=search&origin=*&gsrsearch=japan"
posts: Observable<any>;
constructor(private http: HttpClient) {}
getPosts(){
this.posts = this.http.get(this.ROOT_URL)
}
}
//app.component.html
<input type="text" placeholder="Search for pages..">
<button (click)="getPosts()">Get Posts</button>
<div *ngFor="let post of posts | async">
{{ post | json }}
</div>
<ul class=filter-select>
<li class="filter-select-list">
<p class="wiki-page"></p>
</li>
</ul>
If I insert responseType: text into the response handler, I am able to read the returned data as an error in dev console.