I tried searching for answers in the already asked similar questions but failed to resolve the problem
I am new to Angular 4 and trying to make a simple Angular frontend for a hypothetical book store. There is a hard-coded dataset present in the app as books.json. But the problem is every time to try to run it I get the following error:
And here's the screenshot of the project directory and the code.
Here is my book.service.ts code :
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { IBook } from './book';
import 'rxjs/add/operator/map';
@Injectable()
export class BookService {
constructor(private _http: Http){}
getBooks(): Observable<IBook[]> {
return this._http
.get("api/books/books.json")
.map((response : Response) => {
return response.json() as IBook[];
});
}
}


api/books/books.jsonis simply not there. Check your path.www/folder. Contents ofassets/folder are simply copied over towww/so this would be the best place to put your.jsonfiles. If you move your.jsontoassets/you should then access it withassets/api/books/books.json.