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.

createUseApi

función Since 1.1.0

Crea useApi para los endpoints GET de un manifiesto público. Los clientes generados (.meeko/generated/clients.*.ts) lo exportan así; un host propio puede hacer lo mismo.

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

Source code src/app/composables/resources/use-api.ts:26

Firma #

ts
function createUseApi<Contract extends Record<string, Record<string, AnyApiOperation>>, Manifest extends Pick<PublicServerManifest, "api">>(manifest: Manifest, options?: ClientOptions): UseApi<ApiQueryContract<Manifest, Contract>>

Type parameters #

Contract extends Record<string, Record<string, AnyApiOperation>>
Manifest extends Pick<PublicServerManifest, 'api'>

Parameters #

manifest Manifest

Manifiesto público con la lista api.

options ClientOptions optional

Opciones de transporte: fetch, baseUrl, cabeceras y CSRF.

Returns #

UseApi<ApiQueryContract<Manifest, Contract>>

El composable useApi. Al llamarlo con una ruta sin endpoint GET lanza TypeError, y fuera del script de un componente, Error.

Example #

ts
import { createBrowserClientOptions, createUseApi } from "@meekojs/meeko/framework";
import type { ApiContract } from "../types/server-contracts.js";

const manifest = { version: 1, api: [{ clientKey: "users", pathname: "/api/users", method: "GET" }], rpc: [] } as const;
export const useApi = createUseApi<ApiContract, typeof manifest>(manifest, createBrowserClientOptions());

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/use-api.ts