Skip to main content
Version: 2.x ๐Ÿšง

GET, HEAD, OPTIONS

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

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

Argumentsโ€‹

    • parameters: { path, query, header } | void
      • Required only if OpenAPI specification defines required parameters
      • If the operation has no required parameters according to OpenAPI, you can omit this argument
    • baseUrl - Required base URL for the requestFn
    • signal - An optional AbortSignal to cancel the request
    • meta - An optional object that will be passed to the requestFn
  1. requestFn?: RequestFn
    • Optional, 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';
import { createAPIClient } from './api'; // generated by OpenAPI Qraft CLI

const api = createAPIClient({
requestFn,
baseUrl: 'https://petstore3.swagger.io/api/v3',
});

/**
* Executes the request:
* ###
* GET /posts?limit=10
**/
const posts = await api.posts.getPosts(
{
parameters: { query: { limit: 10 } }
}
);