문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| angular:http-observables [2019/01/15 04:43] – taekgu | angular:http-observables [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| 줄 15: | 줄 15: | ||
| * Reactive Extensions from Javascript | * Reactive Extensions from Javascript | ||
| * External library to work with Obserables | * External library to work with Obserables | ||
| + | |||
| + | <file javascript employee.service.ts> | ||
| + | import { Injectable } from ' | ||
| + | import { HttpClient, HttpErrorResponse } from ' | ||
| + | import { IEmployee } from ' | ||
| + | import { Observable } from ' | ||
| + | import { catchError, retry } from ' | ||
| + | |||
| + | // @Injectable({ | ||
| + | // | ||
| + | // }) | ||
| + | @Injectable() | ||
| + | export class EmployeeService { | ||
| + | private _url: string = "/ | ||
| + | |||
| + | constructor(private http: HttpClient) { } | ||
| + | |||
| + | getEmployees(): | ||
| + | return this.http.get< | ||
| + | .pipe( | ||
| + | catchError(this.errorHandler) | ||
| + | ); | ||
| + | } | ||
| + | errorHandler(error: | ||
| + | return Observable.throw(error.message || " | ||
| + | } | ||
| + | } | ||
| + | </ | ||