> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/estebansalas94/Prueba-Soporte/llms.txt
> Use this file to discover all available pages before exploring further.

# List tasks

> Returns all incomplete tasks assigned to any user. Completed tasks are excluded from the response.

<Note>
  This endpoint requires an active authenticated session. Unauthenticated requests are redirected to the login page.
</Note>

## Endpoint

```
GET /tasks/index
```

## Description

Returns a JSON array of all tasks where `completed = 0`. Completed tasks are permanently filtered out and will not appear in this response. The frontend calls this endpoint on initial page load and after every mutating operation (create, complete, delete).

## Query parameters

<ParamField query="showAll" type="boolean">
  Optional. Passed by the Vuex `fetchTasks` action. Defaults to `false`. The current controller implementation does not filter on this value — all incomplete tasks are returned regardless. Reserved for future use.
</ParamField>

## Response

Returns a JSON array of task objects. Returns an empty array `[]` when no incomplete tasks exist.

### Response fields

<ResponseField name="id" type="integer">
  Unique identifier for the task.
</ResponseField>

<ResponseField name="user_id" type="integer">
  ID of the user the task is assigned to.
</ResponseField>

<ResponseField name="title" type="string">
  Short title of the task. Maximum 255 characters.
</ResponseField>

<ResponseField name="description" type="string">
  Detailed description of the task. Maximum 500 characters.
</ResponseField>

<ResponseField name="completed" type="integer">
  Completion flag. Always `0` in this response — completed tasks are excluded.
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp of when the task was created.
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp of when the task was last updated.
</ResponseField>

## Example response

```json theme={null}
[
  {
    "id": 1,
    "user_id": 3,
    "title": "Review pull request",
    "description": "Check the open PR for the billing module.",
    "completed": 0,
    "created_at": "2026-03-18T10:00:00.000000Z",
    "updated_at": "2026-03-18T10:00:00.000000Z"
  },
  {
    "id": 2,
    "user_id": 5,
    "title": "Write unit tests",
    "description": "Cover the TaskController with feature tests.",
    "completed": 0,
    "created_at": "2026-03-18T11:30:00.000000Z",
    "updated_at": "2026-03-18T11:30:00.000000Z"
  }
]
```

## Controller code

```php theme={null}
// app/Http/Controllers/TaskController.php

public function index()
{
    $tasks = Task::where('completed', 0)->get();
    return response()->json($tasks);
}
```

## Frontend Axios call

```javascript theme={null}
// resources/js/store.js — fetchTasks action

fetchTasks({ commit }, showAll = false) {
    try {
        axios.get('/tasks/index', { params: { showAll } })
        .then(response => {
            commit('SET_TASKS', response.data);
        })
        .catch(error => {
            console.error("Error adding task:", error);
        });
    } catch (error) {
        console.error("Error fetching tasks:", error);
    }
},
```
