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.

UseApiMutation

tipo Since 1.2.0

Firma de useApiMutation(ruta, método, opciones?): devuelve una ApiMutation que llama a un endpoint POST, PUT, PATCH o DELETE con mutate({ params, query, body }). Con { retrySafe: { key } } devuelve además RetrySafeMutation; onSuccess y onError avisan de cada intento. Se llama mientras se ejecuta el script de un componente, normalmente en su nivel superior, y no admite await (MEEK055).

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

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

Declaración #

ts
type UseApiMutation<Mutations> = {
	<Path extends keyof Mutations & string, Method extends keyof Mutations[Path] & string>(path: Path, method: Method, options?: MutationOptions<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']> & { readonly retrySafe?: undefined }): ApiMutation<MutationOf<Mutations, Path, Method>>
	<Path extends keyof Mutations & string, Method extends keyof Mutations[Path] & string>(path: Path, method: Method, options: MutationOptions<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']> & { readonly retrySafe: RetrySafeOptions }): ApiMutation<MutationOf<Mutations, Path, Method>> & RetrySafeMutation<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']>
}

Type parameters #

Mutations

Operaciones por ruta y método, normalmente un ApiMutationContract.

Example #

meeko
<script lang="ts">
const create = useApiMutation("/api/notes", "POST");
const sale = useApiMutation("/api/sales", "POST", { retrySafe: { key: "pos:sale" } });
async function add(text: string): Promise<void> {
  await create.mutate({ body: { text } });
}
</script>

Miembros #

(llamada) #

firma de llamada

<Path extends keyof Mutations & string, Method extends keyof Mutations[Path] & string>(path: Path, method: Method, options?: MutationOptions<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']> & { readonly retrySafe?: undefined }): ApiMutation<MutationOf<Mutations, Path, Method>>
<Path extends keyof Mutations & string, Method extends keyof Mutations[Path] & string>(path: Path, method: Method, options: MutationOptions<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']> & { readonly retrySafe: RetrySafeOptions }): ApiMutation<MutationOf<Mutations, Path, Method>> & RetrySafeMutation<ApiMutationInput<MutationOf<Mutations, Path, Method>>, MutationOf<Mutations, Path, Method>['output']>

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