I'm creating app using angular2 and i need to get weather from yahoo weather. I try to do it using http get method but it's give me a error.
import {Component,OnInit,} from "angular2/core";
import {Http} from "angular2/http";
import 'rxjs/add/operator/map';
@Component({
templateUrl:'app/contact/contact.html',
})
export class ContactComponent{
constructor (private http: Http) {}
public url:string= "http://weather.yahooapis.com/forecastjson?w=2295424";
ngOnInit(url:string) {
return this.http.get(url).map(res => {
return res.json();
}).subscribe((response) => { console.log(response) });
}
}
Error I get is
EXCEPTION: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
can anyone help me with this?.