Open History to see the last commit
1import { HttpClient } from '@angular/common/http'
2import { Injectable, inject } from '@angular/core'
3import type { Post } from './types'
4β
5@Injectable({
6 providedIn: 'root',
7})
8export class PostsAPI {
9 readonly #http = inject(HttpClient)
10β
11 getPosts = () =>
12 this.#http.get<Array<Post>>('https://jsonplaceholder.typicode.com/posts')
13β
14 getPost = (id: number) =>
15 this.#http.get<Post>(`https://jsonplaceholder.typicode.com/posts/${id}`)
16}