Closed briighter closed 2 years ago
One possible solution is to keep the localhost server running in a seperate terminal. Once you run the server by cmd 'npm run server', open another terminal, and run 'npm start' to start your app.
Has this been resolved? Seems like there was a step missing, in the tutorial, namely actually serving the events array, or pointing the new server to it?
Yeah... I'm having the same issue since the past 3days... I'm still trying to figure this out. Any one with solution should please inform us
Module 14 Lesson 3 Moving Data Storage to the Server
Getting Error:
HttpErrorResponse {headers: HttpHeaders, status: 404, statusText: "Not Found", url: "http://localhost:4200/api/events", ok: false, …}
proxy.conf.json
{ "/api": { "target": "http://localhost:8808", "secure": false } }
package.json
"scripts": { "start": "ng serve --proxy-config proxy.conf.json", },
event.service.ts
getEvents(): Observable<IEvent[]> { return this.http.get<IEvent[]>('/api/events') .pipe(catchError(this.handleError<IEvent[]>('getEvents', []))) }
private handleError<T>(operation = 'operation', result?: T) { return (error: any): Observable<T> => { console.error(error) return of(result as T) } }