GET, HEAD, OPTIONS
The method allows you to execute a Queries without TanStack's QueryClient.
- With parameters
- With queryKey
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- AbortSignalto cancel the request
- meta- An optional object that will be passed to the- requestFn
 
- requestFn?: RequestFn- Optional, a function that will be used to execute the request
 
const result = qraft.<service>.<operation>(
  {
    queryKey,
    baseUrl,
    signal,
    meta,
  },
  requestFn
);
Argumentsโ
- 
- queryKey: QueryKey | 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- AbortSignalto cancel the request
- meta- An optional object that will be passed to the- requestFn
 
- requestFn?: RequestFn- Optional, a function that will be used to execute the request.
 
Returnsโ
result: Promise<T> - The result of the query execution
Examplesโ
- With parameters
- With queryKey
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 } }
  }
);
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(
  {
    queryKey: qraft.posts.getPosts.getQueryKey({ query: { limit: 10 } }),
    baseUrl: 'https://custom-api.sandbox.monite.com/v1', // optionally, you can specify the base URL
  }
);