Skip to main content
Version: 1.x

GET, HEAD, OPTIONS

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

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

const result = qraft.<service>.<operation>(
{
parameters,
baseUrl,
signal,
meta,
queryKey,
},
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
    • signal - An optional AbortSignal to cancel the request
    • meta - An optional object that will be passed to the requestFn
    • queryKey: QueryKey could be provided instead of parameters
  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:
* ###
* GET /posts?limit=10
**/
const posts = await qraft.posts.getPosts(
{
parameters: { query: { limit: 10 } },
baseUrl: 'https://api.sandbox.monite.com/v1',
},
requestFn
);