---
title: Create a GET endpoint
project: LessCode
version: 1.0
section: recipes
language: en
license: MIT
url: https://totaljs.es/docs/lesscode/1-0/recipes/get-endpoint/
updated: 2026-11-19T04:41:14.691Z
---

# Create a GET endpoint

> Build an HTTP endpoint that reads a query argument and answers with JSON.

This endpoint answers `GET /api/hello/`. It greets the name you pass in the address, or the world when there is none.

![Route, Code and Response nodes connected for the hello endpoint](/files/Jap1ac2uO61f.webp)

You need the **Route**, **Code** and **Response** components. See [Download components](../../guides/download-components/).

## Build it

1. Drag **Route**, **Code** and **Response** onto the canvas.
2. Connect **Request** of Route to **Input** of Code, and **Output** of Code to **Response** of Response.
3. Double-click **Route**. Keep **Method** `GET`, set **Relative URL address** to `/api/hello/` and select **APPLY**.
4. Double-click **Code**, replace the code with the code below and select **APPLY**.
5. Double-click **Response**, empty **Path for reading value** and select **APPLY**.
6. Select **APPLY** in the toolbar, then **Continue**.

The code of the Code node:

```js
send({ message: 'Hello, ' + (value.query.name || 'world') + '!' });
```

`value` is the request that Route sends: with **Send to output** set to **Everything**, the query arguments are in `value.query`.

## Try it

```bash
curl 'http://localhost:8000/api/hello/?name=Jane'
```

```json
{"message":"Hello, Jane!"}
```

Without a name:

```bash
curl http://localhost:8000/api/hello/
```

```json
{"message":"Hello, world!"}
```

## Why empty the path

By default, Response sends only the `response` property of the data it receives. Empty **Path for reading value** to send the whole object, or send your data inside `response`, as in [Create a POST endpoint](../post-endpoint/).

See also [Route](../../reference/route/) and [Response](../../reference/response/).
