Calling APIs from NestJS, for Spring Developers: One Line, Four Traps

30 September 2026 nestjstypescriptnodejsjavaspring-boot
PDF The design sheet The full architecture and the verified references. Free, no email.
Thumbnail for Calling APIs from NestJS, for Spring Developers: One Line, Four Traps 4:54
Watch on YouTube, or read on below.
Run this yourself → Clone the repo, docker compose up, and watch it happen

The API you call takes ten seconds to answer. Spring’s RestClient, the HttpService from @nestjs/axios, and the new HttpClient from @nestjs/http-client all waited the full ten seconds by default. Measured on 30 September 2026 against a real downstream server.

At the time of recording the Nest docs describe @nestjs/http-client, version 0.0.1, built on fetch; @nestjs/axios remains available and is what most existing code uses.

When it gives up

With a one second timeout, RestClient gave up after 1.2 seconds, @nestjs/axios after 1.0, and the new client after 3.2 seconds with three hits at the downstream. The downstream saw the caller hang up at one second and still finished its ten seconds of work: a timeout bounds your wait, it does not cancel theirs.

Whether it ran

HttpService.get() returns an Observable and sent nothing until converted with firstValueFrom; WebClient without subscribe did the same. RestClient and the new HttpClient run when called.

What counts as failure

All three clients turned a 500 into an error by default. Plain fetch resolved with ok false.

Whether it tries again

The new client retries by default, and its timeout applies per attempt, which is where the three seconds came from. A GET that always failed was sent three times, a POST once, and a PUT three times: safe only if the endpoint really is idempotent. RestClient and @nestjs/axios tried once.

The full code for every measurement is in the repository, and the free design sheet above has the checklist on one page.


Watch next

New videos land on Code with Sam - subscribe there if this was useful.

Get the interview pack

A free, practical pack for engineers preparing for senior backend interviews - the questions that actually get asked, and how to answer them like someone who has done the work.

New articles and videos when they land. No spam, and one click to leave.