I'm doing a tutorial and I'm supposed to get a list of books to show up, but I get a console error saying "http://localhost:4200/api/books.json 404 (Not Found)".
If I visit localhost:3000/api/books.json in my browser, I can see the seeded info. Should my app be trying for localhost:3000 or is it supposed to be using localhost:4200?
app/client/src/app/book-list/book-list-component.ts
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'app-book-list',
templateUrl: './book-list.component.html',
styleUrls: ['./book-list.component.css']
})
export class BookListComponent implements OnInit {
books: any;
constructor(private http: Http) { }
ngOnInit() {
this.http.get('/api/books.json')
.subscribe(response => this.books = response.json());
}
}
app/client/src/app/book-list/book-list-component.html
<p>
book-list works!
</p>
<ul>
<li *ngFor="let book of books">{{ book.name }}</li>
</ul>
Here is the rest of the code base in case you need to look at the setup: https://github.com/theresaluu/tut-home-library-spike
