I am new to angular and going through pluralsight tutorials, i am stuck at a point and not able to go further, my problem is like i have a json file products.json and i am trying to read from Http get method, the application throwing an exception on console which is mentioned below.
GET http://localhost:4200/api/products.json 404 (Not Found)
below is my app structure
here is my ts code.
import { Injectable } from "@angular/core";
import { IProduct } from "./product";
import { Http, Response } from "@angular/Http";
import { Observable } from "rxjs/Observable";
import "rxjs/add/operator/map";
import "rxjs/add/operator/do";
import "rxjs/add/operator/catch";
@Injectable()
export class ProductService {
private _productUrl: string = "../data/products/products.json";
constructor(private _http: Http){}
getProducts():Observable< IProduct[]> {
return this._http.get("/api/products.json")
.map((response: Response) => <IProduct[]>response.json())
.do(data => console.log('All: ' + JSON.stringify(data)))
.catch(this.handleError);
}
handleError(error: Response) {
console.log(error);
return Observable.throw(error.json().error || 'system error');
}
}
Please let me know, if i am doing something wrong. thanks in advance!

http://localhost:4200/api/products.json) directly in the browser's address bar (outside of angular)? Probably a 404 I am guessing.