Skip to content

Instantly share code, notes, and snippets.

@lorenzojkrl
Created March 21, 2022 15:33
Show Gist options
  • Save lorenzojkrl/dcb4af33e86b1b48e344afdb2bc9fb13 to your computer and use it in GitHub Desktop.
Save lorenzojkrl/dcb4af33e86b1b48e344afdb2bc9fb13 to your computer and use it in GitHub Desktop.
Declarative
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { tap } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class TodoService {
private todoUrl = 'https://jsonplaceholder.typicode.com/todos/1';
constructor(private http: HttpClient) {}
todo$ = 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