react-code-dataset / react-query /examples /angular /basic-persister /src /app /services /posts-service.ts
Download react-query/examples/angular/basic-persister/src/app/services/posts-service.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 486 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/basic-persister/src/app/services/posts-service.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/basic-persister/src/app/services/posts-service.ts
-
curl -L -o posts-service.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/basic-persister/src/app/services/posts-service.ts
486 Bytes
| import { HttpClient } from '@angular/common/http' | |
| import { Injectable, inject } from '@angular/core' | |
| ({ | |
| providedIn: 'root', | |
| }) | |
| export class PostsService { | |
| #http = inject(HttpClient) | |
| postById$ = (postId: number) => | |
| this.#http.get<Post>(`https://jsonplaceholder.typicode.com/posts/${postId}`) | |
| allPosts$ = () => | |
| this.#http.get<Array<Post>>('https://jsonplaceholder.typicode.com/posts') | |
| } | |
| export interface Post { | |
| id: number | |
| title: string | |
| body: string | |
| } | |