HTTP Client

Web applications often need to fetch some data with HTTP requests. Entropy ships with a handy HttpClient service that helps creating API requests.

Getting Started

To get started with the client, simply import and inject the HttpClient service:

      

src/movies/movie.controller.ts

import { HttpClient } from '@entropy/http'; import { Controller } from '@entropy/router'; export class MovieController extends Controller { private readonly http = inject(HttpClient); }

Sending Requests

To fetch some data from an origin, use one of available methods (get, patch, post, put, options, trace, head, and delete):

      

src/movies/movie.controller.ts

interface Movie { title: string; url: string; duration: number; } const movies = await this.http.get<Movie[]>('https://movie-api.com/movies');
Response type declaration is only build-time check so you should handle errors in case the response is invalid.
CLI Localization