Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

UseApi

tipo Since 1.1.0

Firma de useApi(ruta, opciones?, recarga?): lee un endpoint GET por su ruta y devuelve un DataResource. Sólo se llama en el nivel superior del <script> (MEEK054); con await, la página no se renderiza hasta tener los datos. Desde 1.5, el tercer argumento son las DataResourceOptions (keepPrevious y, desde 1.7, debounceMs y enabled).

ts
import type { UseApi } from "@meekojs/meeko/framework";

Source code src/app/composables/resources/engine.ts:295

Declaración #

ts
type UseApi<Queries> = <Path extends keyof Queries & string>(path: Path, ...options: ApiQueryArguments<QueryOf<Queries, Path>>) => DataResource<QueryOf<Queries, Path>['output']>

Type parameters #

Queries

Operaciones GET por ruta, normalmente un ApiQueryContract.

Example #

meeko
<script lang="ts">
const props = defineProps<{ params: { id: string }; search: Record<string, string | string[]> }>();
const user = await useApi("/api/users/[id]", { params: { id: props.params.id } });
</script>
<template><h1>{user.data.value.name}</h1></template>

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/app/composables/resources/engine.ts