---
title: Return database rows as JSON
project: TAS
version: 10.0
section: recipes
language: en
license: Total.js Enterprise
url: https://totaljs.es/docs/tas/10-0/recipes/rows-as-json/
updated: 2026-11-20T06:40:19.031Z
---

# Return database rows as JSON

> Build a flow that answers a request with the rows of a database.

This recipe publishes the customers of a `Customers` database at their own address.

**1.** Create the `Customers` database with the columns you need. See [Databases](../../guides/databases/).

**2.** Open **Flows**, select **Create**, name the flow `Customer API` and select **SUBMIT**.

**3.** Open the flow. From the **Databases** group, drag **View endpoint**, **Customers** and **View response** onto the area.

**4.** Connect **Request** of the view to **Input** of **Customers**, and **Output** of **Customers** to **Response** of **View response**.

![The finished Customer API flow](/files/Jaswvz2j860f.webp)

**5.** Double-click **Customers** and replace the code with:

```js
return FIND();
```

**6.** Select **APPLY** in the settings, then **APPLY** and **Continue** in the designer.

**7.** Find the address of the view:

```sql
SELECT name, url FROM tbl_view WHERE isremoved = false;
```

**8.** Open the address in the browser where you are signed in to TAS. TAS answers with the rows:

```json
[{"id":"JasoGx1cB61f","name":"Jane Doe","email":"jane@example.com","active":true}]
```

## Return one row

Change the code of **Customers** to read the `id` from the query string:

```js
return READ().where('id', data.query.id);
```

Then call the address with `?id=` and the identifier of a row. Connect the **Error** output to **View response** too, so that the request also ends when the code fails.
