---
title: Call an HTTP API
project: LessCode
version: 1.0
section: recipes
language: en
license: MIT
url: https://totaljs.es/docs/lesscode/1-0/recipes/call-http-api/
updated: 2026-11-19T04:41:14.223Z
---

# Call an HTTP API

> Turn an HTTP address into a reusable node with Link endpoint and send data to it.

**Link endpoint** creates a component that calls one HTTP address. The component has two outputs: **Output** for a successful answer and **Error** for an answer with an error status, such as `400`.

This example calls the endpoint from [Create a POST endpoint](../post-endpoint/).

## Create the component

1. Select **Add** (plus) in the toolbar, then **Link endpoint**.
2. Set **Name** to `Orders API`, **Group name** to `My APIs`, **HTTP method** to `POST`, **Data serialization** to `JSON` and **URL address** to `http://localhost:8000/api/orders/`.
3. Select **CREATE**.

![The Link endpoint form](/files/Jap1aV2qO61f.webp)

The component appears in the list on the left under **My APIs**. You can use it as many times as you like.

| Field | What to enter |
|---|---|
| **Name** | The name of the component. Required. |
| **Group name** | The heading it appears under in the list. |
| **Icon** | The icon of the component. |
| **HTTP method** | `POST`, `GET`, `PUT`, `PATCH` or `DELETE`. |
| **Data serialization** | **JSON** or **URL encode**, for the body of the request. |
| **URL address** | The address to call. Required. |
| **Custom headers** | A header name and value. Press Enter to confirm each one. |
| **Compress data via GZIP** | Compresses the data you send. |
| **Read me** | A description, shown by **Read information**. |

## Use it

1. Drag **Trigger**, **Orders API** and two **Print** nodes onto the canvas.
2. Connect Trigger to the input of Orders API, **Output** to the first Print and **Error** to the second Print.
3. Double-click **Trigger**, choose **Object**, clear **Random data**, set **Data** to `{ product: 'Demo product', quantity: 3 }` and select **APPLY**.
4. Select **APPLY** in the toolbar, then **Continue**.
5. Select **Run** on the Trigger.

The first Print shows the answer of the API:

```json
{"success":true,"product":"Demo product","quantity":3}
```

![The Trigger, Orders API and Print nodes after Run](/files/Jap1aY2rO60f.webp)

When the API answers with an error, the answer goes to the **Error** output. With `{ quantity: 1 }` as Trigger data, the second Print shows:

```json
{"error":"The product is required."}
```
