Skip to content

Instantly share code, notes, and snippets.

@lorenzojkrl
Last active March 21, 2022 15:02
Show Gist options
  • Save lorenzojkrl/babc927b1f41e403c5cce0a7260d9147 to your computer and use it in GitHub Desktop.
Save lorenzojkrl/babc927b1f41e403c5cce0a7260d9147 to your computer and use it in GitHub Desktop.
Classic Pattern
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