jmcooper / angular-fundamentals-files

353 stars 536 forks source link

Error: http://localhost:8808 (ECONNREFUSED) #17

Closed briighter closed 2 years ago

briighter commented 3 years ago

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) } }

chyuting commented 3 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.

Incerto13 commented 2 years ago

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?

Kelvinesthy commented 2 years ago

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

dystophic commented 2 years ago

Hi Guys,

The solution can be found here.