Last active
March 21, 2022 15:02
-
-
Save lorenzojkrl/babc927b1f41e403c5cce0a7260d9147 to your computer and use it in GitHub Desktop.
Classic Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient } from '@angular/common/http'; | |
import { Injectable } from '@angular/core'; | |
import { Observable } from 'rxjs'; | |
import { tap } from 'rxjs/operators'; | |
import { ToDo } from './model'; | |
@Injectable({ providedIn: 'root' }) | |
export class TodoService { | |
private todoUrl = 'https://jsonplaceholder.typicode.com/todos/1'; | |
constructor(private http: HttpClient) {} | |
getTodo(): Observable<ToDo> { | |
return this.http.get(this.todoUrl).pipe(tap(console.log)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment