I am trying to request a web page with a http call and harwest the data.
I could avoid the cross-origin with a chrome plug-in but still when I make the request, the response is always "null".
How could I fetch a html page inside my angular app as a json object ?
ngOnInit(): void {
// Make the HTTP request:
this.http.get('http://www.hurriyet.com.tr/gundem/').subscribe(data => {
this.results = data;
});
}
You should make sure the request URL ends with .json such as:
http://www.hurriyet.com.tr/gundem/gundem.json
This will sort the mime type out automatically. Something like this:
this.http.get('http://www.hurriyet.com.tr/gundem/gundem.json').subscribe(data => {
// Read the result field from the JSON response.
this.results = data['results'];
});
You may also need to use data.json() in your promise resolution code.