Skip to main content
Version: 1.x

POST, PUT, PATCH, DELETE

The method allows you to execute a Mutations without TanStack's QueryClient.

import { requestFn } from '@openapi-qraft/react';

const result = qraft.<service>.<operation>(
{
parameters,
baseUrl,
signal,
meta,
},
requestFn
);

Argumentsโ€‹

    • parameters: { path, query, header } | {}
      • Required, OpenAPI request parameters for the query, strictly-typed โœจ
      • If operation does not require parameters, you must pass an empty object {} for strictness
    • baseUrl - Required base URL for the requestFn
  1. requestFn: RequestFn
    • Required, a function that will be used to execute the request

Returnsโ€‹

result: Promise<T> - The result of the query execution

Examplesโ€‹

import { requestFn } from '@openapi-qraft/react';

/**
* Executes the request:
* ###
* PATCH /posts/123
*
* { "title": "New title" }
**/
const posts = await qraft.posts.updatePost(
{
parameters: { path: { post_id: 123 } },
body: { title: 'New title' },
baseUrl: 'https://api.sandbox.monite.com/v1',
},
requestFn
);