[{"data":1,"prerenderedAt":1447},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fwrite-your-client":3},{"id":4,"title":5,"body":6,"description":1429,"extension":1436,"frontmatter":1437,"heading":5,"meta":1438,"navigation":1439,"order":1440,"path":1441,"seo":1442,"sitemap":1443,"source":4,"stem":1444,"__hash__":1445,"hasPopups":1446},"extensions\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fwrite-your-client.md","Write your client",{"type":7,"value":8,"toc":1428},"minimark",[9,22,27,91,106,132,173,179,183,476,515,519,526,1412,1420],[10,11,12,13,21],"p",{},"The generated functions import your module through ",[14,15,17],"a",{"href":16},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Foptions#importpath",[18,19,20],"code",{},"importPath",". That module is the only runtime code the generated functions call, and you own it.",[23,24,26],"h2",{"id":25},"required-exports","Required exports",[28,29,30,46],"table",{},[31,32,33],"thead",{},[34,35,36,40,43],"tr",{},[37,38,39],"th",{},"Export",[37,41,42],{},"Kind",[37,44,45],{},"Purpose",[47,48,49,66,79],"tbody",{},[34,50,51,57,60],{},[52,53,54],"td",{},[18,55,56],{},"client",[52,58,59],{},"function",[52,61,62,63,65],{},"Sends the request. Every generated function calls it, unless a call passes its own ",[18,64,56],{},".",[34,67,68,73,76],{},[52,69,70],{},[18,71,72],{},"Options",[52,74,75],{},"type",[52,77,78],{},"The grouped options object a generated function accepts.",[34,80,81,86,88],{},[52,82,83],{},[18,84,85],{},"RequestResult",[52,87,75],{},[52,89,90],{},"What a generated function resolves to.",[10,92,93,94,97,98,101,102,105],{},"If your spec has server-sent event operations, also export ",[18,95,96],{},"toEventStream"," and the ",[18,99,100],{},"EventStreamResult"," and ",[18,103,104],{},"SuccessOf"," types.",[10,107,108,109,112,113,112,116,119,120,123,124,127,128,131],{},"The query plugins (",[18,110,111],{},"@kubb\u002Fplugin-react-query",", ",[18,114,115],{},"@kubb\u002Fplugin-vue-query",[18,117,118],{},"@kubb\u002Fplugin-swr",") and ",[18,121,122],{},"@kubb\u002Fplugin-mcp"," call the generated functions with ",[18,125,126],{},"throwOnError: true"," and read ",[18,129,130],{},"data"," off the result. The query plugins also import two more types from your module:",[28,133,134,144],{},[31,135,136],{},[34,137,138,140,142],{},[37,139,39],{},[37,141,42],{},[37,143,45],{},[47,145,146,161],{},[34,147,148,153,155],{},[52,149,150],{},[18,151,152],{},"RequestConfig",[52,154,75],{},[52,156,157,158,160],{},"The per-call ",[18,159,56],{}," options a hook accepts, minus the request fields.",[34,162,163,168,170],{},[52,164,165],{},[18,166,167],{},"ResponseErrorConfig",[52,169,75],{},[52,171,172],{},"The error type of a failed hook, given the spec's error type.",[10,174,175,176,178],{},"With a relative ",[18,177,20],{},", the hooks resolve it from the generated operation file, so one path serves both.",[23,180,182],{"id":181},"what-a-generated-function-looks-like","What a generated function looks like",[184,185,189],"pre",{"language":186,"code":187,"class":188},"typescript","import type { Options, RequestResult } from '..\u002F..\u002F..\u002Fclient'\nimport type { GetPetByIdOptions, GetPetByIdResponses } from '..\u002F..\u002Fmodels\u002Fpet\u002FGetPetById'\nimport { client } from '..\u002F..\u002F..\u002Fclient'\n\nexport function getPetById\u003CThrowOnError extends boolean = true>(\n  options: Options\u003CGetPetByIdOptions, ThrowOnError>,\n): Promise\u003CRequestResult\u003CGetPetByIdResponses, ThrowOnError>> {\n  const { client: request = client, ...config } = options\n\n  return request({\n    method: 'GET',\n    url: '\u002Fpet\u002F{petId}',\n    security: [{ type: 'apiKey', name: 'api_key', in: 'header' }, { type: 'oauth2' }],\n    ...config,\n    throwOnError: config.throwOnError ?? true,\n  }) as Promise\u003CRequestResult\u003CGetPetByIdResponses, ThrowOnError>>\n}","shiki shiki-themes github-light github-dark dark:github-dark",[18,190,192,215,216,215,230,215,241,215,243,215,277,215,301,215,327,215,363,215,365,215,376,215,387,215,397,215,426,215,434,215,446,215,471],{"class":191},"language-typescript",[193,194,197,201,204,208,211],"span",{"class":195,"style":196},"line","display: inline",[193,198,200],{"style":199},"color:#D73A49;--shiki-dark:#F97583","import",[193,202,203],{"style":199}," type",[193,205,207],{"style":206},"color:#24292E;--shiki-dark:#E1E4E8"," { Options, RequestResult } ",[193,209,210],{"style":199},"from",[193,212,214],{"style":213},"color:#032F62;--shiki-dark:#9ECBFF"," '..\u002F..\u002F..\u002Fclient'","\n",[193,217,218,220,222,225,227],{"class":195,"style":196},[193,219,200],{"style":199},[193,221,203],{"style":199},[193,223,224],{"style":206}," { GetPetByIdOptions, GetPetByIdResponses } ",[193,226,210],{"style":199},[193,228,229],{"style":213}," '..\u002F..\u002Fmodels\u002Fpet\u002FGetPetById'",[193,231,232,234,237,239],{"class":195,"style":196},[193,233,200],{"style":199},[193,235,236],{"style":206}," { client } ",[193,238,210],{"style":199},[193,240,214],{"style":213},[193,242],{"class":195,"style":196},[193,244,245,248,251,255,258,261,264,268,271,274],{"class":195,"style":196},[193,246,247],{"style":199},"export",[193,249,250],{"style":199}," function",[193,252,254],{"style":253},"color:#6F42C1;--shiki-dark:#B392F0"," getPetById",[193,256,257],{"style":206},"\u003C",[193,259,260],{"style":253},"ThrowOnError",[193,262,263],{"style":199}," extends",[193,265,267],{"style":266},"color:#005CC5;--shiki-dark:#79B8FF"," boolean",[193,269,270],{"style":199}," =",[193,272,273],{"style":266}," true",[193,275,276],{"style":206},">(",[193,278,279,283,286,289,291,294,296,298],{"class":195,"style":196},[193,280,282],{"style":281},"color:#E36209;--shiki-dark:#FFAB70","  options",[193,284,285],{"style":199},":",[193,287,288],{"style":253}," Options",[193,290,257],{"style":206},[193,292,293],{"style":253},"GetPetByIdOptions",[193,295,112],{"style":206},[193,297,260],{"style":253},[193,299,300],{"style":206},">,",[193,302,303,306,308,311,313,315,317,320,322,324],{"class":195,"style":196},[193,304,305],{"style":206},")",[193,307,285],{"style":199},[193,309,310],{"style":253}," Promise",[193,312,257],{"style":206},[193,314,85],{"style":253},[193,316,257],{"style":206},[193,318,319],{"style":253},"GetPetByIdResponses",[193,321,112],{"style":206},[193,323,260],{"style":253},[193,325,326],{"style":206},">> {",[193,328,329,332,335,337,340,343,345,348,351,354,357,360],{"class":195,"style":196},[193,330,331],{"style":199},"  const",[193,333,334],{"style":206}," { ",[193,336,56],{"style":281},[193,338,339],{"style":206},": ",[193,341,342],{"style":266},"request",[193,344,270],{"style":199},[193,346,347],{"style":206}," client, ",[193,349,350],{"style":199},"...",[193,352,353],{"style":266},"config",[193,355,356],{"style":206}," } ",[193,358,359],{"style":199},"=",[193,361,362],{"style":206}," options",[193,364],{"class":195,"style":196},[193,366,367,370,373],{"class":195,"style":196},[193,368,369],{"style":199},"  return",[193,371,372],{"style":253}," request",[193,374,375],{"style":206},"({",[193,377,378,381,384],{"class":195,"style":196},[193,379,380],{"style":206},"    method: ",[193,382,383],{"style":213},"'GET'",[193,385,386],{"style":206},",",[193,388,389,392,395],{"class":195,"style":196},[193,390,391],{"style":206},"    url: ",[193,393,394],{"style":213},"'\u002Fpet\u002F{petId}'",[193,396,386],{"style":206},[193,398,399,402,405,408,411,414,417,420,423],{"class":195,"style":196},[193,400,401],{"style":206},"    security: [{ type: ",[193,403,404],{"style":213},"'apiKey'",[193,406,407],{"style":206},", name: ",[193,409,410],{"style":213},"'api_key'",[193,412,413],{"style":206},", in: ",[193,415,416],{"style":213},"'header'",[193,418,419],{"style":206}," }, { type: ",[193,421,422],{"style":213},"'oauth2'",[193,424,425],{"style":206}," }],",[193,427,428,431],{"class":195,"style":196},[193,429,430],{"style":199},"    ...",[193,432,433],{"style":206},"config,",[193,435,436,439,442,444],{"class":195,"style":196},[193,437,438],{"style":206},"    throwOnError: config.throwOnError ",[193,440,441],{"style":199},"??",[193,443,273],{"style":266},[193,445,386],{"style":206},[193,447,448,451,454,456,458,460,462,464,466,468],{"class":195,"style":196},[193,449,450],{"style":206},"  }) ",[193,452,453],{"style":199},"as",[193,455,310],{"style":253},[193,457,257],{"style":206},[193,459,85],{"style":253},[193,461,257],{"style":206},[193,463,319],{"style":253},[193,465,112],{"style":206},[193,467,260],{"style":253},[193,469,470],{"style":206},">>",[193,472,473],{"class":195,"style":196},[193,474,475],{"style":206},"}",[10,477,478,479,481,482,485,486,489,490,493,494,497,498,112,501,112,504,507,508,507,511,514],{},"Your ",[18,480,56],{}," receives ",[18,483,484],{},"method",", the ",[18,487,488],{},"url"," template with ",[18,491,492],{},"{param}"," placeholders, ",[18,495,496],{},"security",", the grouped ",[18,499,500],{},"path",[18,502,503],{},"query",[18,505,506],{},"headers",", and ",[18,509,510],{},"body",[18,512,513],{},"throwOnError",". It returns a promise.",[23,516,518],{"id":517},"a-minimal-client","A minimal client",[10,520,521,522,525],{},"The client below uses ",[18,523,524],{},"fetch",". Replace the transport with the HTTP library you use.",[184,527,530],{"language":186,"filename":528,"code":529,"class":188},"src\u002Fclient.ts","export type RequestConfig = {\n  method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n  url: string\n  baseURL?: string\n  headers?: object\n  path?: object\n  query?: object\n  body?: unknown\n  signal?: AbortSignal\n  throwOnError?: boolean\n  security?: Array\u003C{ type: string; name?: string; in?: string }>\n  client?: typeof client\n}\n\ntype DataShape = { body?: unknown; headers?: unknown; path?: unknown; query?: unknown }\n\nexport type Options\u003CTData extends DataShape, ThrowOnError extends boolean = true> = Omit\u003CRequestConfig, keyof DataShape | 'url' | 'method'> &\n  TData & { throwOnError?: ThrowOnError }\n\nexport type RequestResult\u003CTResponses, ThrowOnError extends boolean = true> = ThrowOnError extends true\n  ? { data: TResponses[keyof TResponses]; error: undefined; response: Response }\n  : { data: TResponses[keyof TResponses]; error: undefined; response: Response } | { data: undefined; error: {}; response: Response }\n\n\u002F\u002F Only needed by the query plugins: what a failed hook rejects with.\nexport type ResponseErrorConfig\u003CTError = unknown> = Error & { body?: TError }\n\n\u002F\u002F Set this to your API host. `new URL()` needs an absolute URL.\nexport const settings = { baseURL: 'https:\u002F\u002Fpetstore3.swagger.io\u002Fapi\u002Fv3' }\n\nexport async function client(config: RequestConfig) {\n  const path: Record\u003Cstring, unknown> = { ...config.path }\n  const url = new URL((config.baseURL ?? settings.baseURL) + config.url.replace(\u002F\\{(\\w+)\\}\u002Fg, (_, key) => encodeURIComponent(String(path[key]))))\n\n  const response = await fetch(url, {\n    method: config.method,\n    headers: config.headers as Record\u003Cstring, string>,\n    body: config.body === undefined ? undefined : JSON.stringify(config.body),\n    signal: config.signal,\n  })\n  const body = await response.json().catch(() => undefined)\n\n  if (response.ok) return { data: body, error: undefined, response }\n  if (config.throwOnError ?? true) throw new Error(`Request failed with status ${response.status}`)\n  return { data: undefined, error: body ?? { status: response.status }, response }\n}",[18,531,532,215,546,215,587,215,597,215,607,215,617,215,626,215,635,215,645,215,655,215,664,215,705,215,718,215,722,215,724,215,768,215,770,215,833,215,852,215,854,215,890,215,934,215,999,215,1001,215,1007,215,1045,215,1047,215,1052,215,1072,215,1074,215,1097,215,1130,215,1217,215,1219,215,1237,215,1242,215,1261,215,1290,215,1295,215,1300,215,1332,215,1334,215,1354,215,1391,215,1408],{"class":191},[193,533,534,536,538,541,543],{"class":195,"style":196},[193,535,247],{"style":199},[193,537,203],{"style":199},[193,539,540],{"style":253}," RequestConfig",[193,542,270],{"style":199},[193,544,545],{"style":206}," {",[193,547,548,551,553,556,559,562,564,567,569,572,574,577,579,582,584],{"class":195,"style":196},[193,549,550],{"style":281},"  method",[193,552,285],{"style":199},[193,554,555],{"style":213}," 'GET'",[193,557,558],{"style":199}," |",[193,560,561],{"style":213}," 'PUT'",[193,563,558],{"style":199},[193,565,566],{"style":213}," 'PATCH'",[193,568,558],{"style":199},[193,570,571],{"style":213}," 'POST'",[193,573,558],{"style":199},[193,575,576],{"style":213}," 'DELETE'",[193,578,558],{"style":199},[193,580,581],{"style":213}," 'OPTIONS'",[193,583,558],{"style":199},[193,585,586],{"style":213}," 'HEAD'",[193,588,589,592,594],{"class":195,"style":196},[193,590,591],{"style":281},"  url",[193,593,285],{"style":199},[193,595,596],{"style":266}," string",[193,598,599,602,605],{"class":195,"style":196},[193,600,601],{"style":281},"  baseURL",[193,603,604],{"style":199},"?:",[193,606,596],{"style":266},[193,608,609,612,614],{"class":195,"style":196},[193,610,611],{"style":281},"  headers",[193,613,604],{"style":199},[193,615,616],{"style":266}," object",[193,618,619,622,624],{"class":195,"style":196},[193,620,621],{"style":281},"  path",[193,623,604],{"style":199},[193,625,616],{"style":266},[193,627,628,631,633],{"class":195,"style":196},[193,629,630],{"style":281},"  query",[193,632,604],{"style":199},[193,634,616],{"style":266},[193,636,637,640,642],{"class":195,"style":196},[193,638,639],{"style":281},"  body",[193,641,604],{"style":199},[193,643,644],{"style":266}," unknown",[193,646,647,650,652],{"class":195,"style":196},[193,648,649],{"style":281},"  signal",[193,651,604],{"style":199},[193,653,654],{"style":253}," AbortSignal",[193,656,657,660,662],{"class":195,"style":196},[193,658,659],{"style":281},"  throwOnError",[193,661,604],{"style":199},[193,663,267],{"style":266},[193,665,666,669,671,674,677,679,681,683,686,689,691,693,695,698,700,702],{"class":195,"style":196},[193,667,668],{"style":281},"  security",[193,670,604],{"style":199},[193,672,673],{"style":253}," Array",[193,675,676],{"style":206},"\u003C{ ",[193,678,75],{"style":281},[193,680,285],{"style":199},[193,682,596],{"style":266},[193,684,685],{"style":206},"; ",[193,687,688],{"style":281},"name",[193,690,604],{"style":199},[193,692,596],{"style":266},[193,694,685],{"style":206},[193,696,697],{"style":281},"in",[193,699,604],{"style":199},[193,701,596],{"style":266},[193,703,704],{"style":206}," }>",[193,706,707,710,712,715],{"class":195,"style":196},[193,708,709],{"style":281},"  client",[193,711,604],{"style":199},[193,713,714],{"style":199}," typeof",[193,716,717],{"style":206}," client",[193,719,720],{"class":195,"style":196},[193,721,475],{"style":206},[193,723],{"class":195,"style":196},[193,725,726,728,731,733,735,737,739,741,743,745,747,749,751,753,755,757,759,761,763,765],{"class":195,"style":196},[193,727,75],{"style":199},[193,729,730],{"style":253}," DataShape",[193,732,270],{"style":199},[193,734,334],{"style":206},[193,736,510],{"style":281},[193,738,604],{"style":199},[193,740,644],{"style":266},[193,742,685],{"style":206},[193,744,506],{"style":281},[193,746,604],{"style":199},[193,748,644],{"style":266},[193,750,685],{"style":206},[193,752,500],{"style":281},[193,754,604],{"style":199},[193,756,644],{"style":266},[193,758,685],{"style":206},[193,760,503],{"style":281},[193,762,604],{"style":199},[193,764,644],{"style":266},[193,766,767],{"style":206}," }",[193,769],{"class":195,"style":196},[193,771,772,774,776,778,780,783,785,787,789,791,793,795,797,799,802,804,807,809,811,813,816,818,820,823,825,828,830],{"class":195,"style":196},[193,773,247],{"style":199},[193,775,203],{"style":199},[193,777,288],{"style":253},[193,779,257],{"style":206},[193,781,782],{"style":253},"TData",[193,784,263],{"style":199},[193,786,730],{"style":253},[193,788,112],{"style":206},[193,790,260],{"style":253},[193,792,263],{"style":199},[193,794,267],{"style":266},[193,796,270],{"style":199},[193,798,273],{"style":266},[193,800,801],{"style":206},"> ",[193,803,359],{"style":199},[193,805,806],{"style":253}," Omit",[193,808,257],{"style":206},[193,810,152],{"style":253},[193,812,112],{"style":206},[193,814,815],{"style":199},"keyof",[193,817,730],{"style":253},[193,819,558],{"style":199},[193,821,822],{"style":213}," 'url'",[193,824,558],{"style":199},[193,826,827],{"style":213}," 'method'",[193,829,801],{"style":206},[193,831,832],{"style":199},"&",[193,834,835,838,841,843,845,847,850],{"class":195,"style":196},[193,836,837],{"style":253},"  TData",[193,839,840],{"style":199}," &",[193,842,334],{"style":206},[193,844,513],{"style":281},[193,846,604],{"style":199},[193,848,849],{"style":253}," ThrowOnError",[193,851,767],{"style":206},[193,853],{"class":195,"style":196},[193,855,856,858,860,863,865,868,870,872,874,876,878,880,882,884,886,888],{"class":195,"style":196},[193,857,247],{"style":199},[193,859,203],{"style":199},[193,861,862],{"style":253}," RequestResult",[193,864,257],{"style":206},[193,866,867],{"style":253},"TResponses",[193,869,112],{"style":206},[193,871,260],{"style":253},[193,873,263],{"style":199},[193,875,267],{"style":266},[193,877,270],{"style":199},[193,879,273],{"style":266},[193,881,801],{"style":206},[193,883,359],{"style":199},[193,885,849],{"style":253},[193,887,263],{"style":199},[193,889,273],{"style":266},[193,891,892,895,897,899,901,904,907,909,911,914,917,919,922,924,927,929,932],{"class":195,"style":196},[193,893,894],{"style":199},"  ?",[193,896,334],{"style":206},[193,898,130],{"style":281},[193,900,285],{"style":199},[193,902,903],{"style":253}," TResponses",[193,905,906],{"style":206},"[",[193,908,815],{"style":199},[193,910,903],{"style":253},[193,912,913],{"style":206},"]; ",[193,915,916],{"style":281},"error",[193,918,285],{"style":199},[193,920,921],{"style":266}," undefined",[193,923,685],{"style":206},[193,925,926],{"style":281},"response",[193,928,285],{"style":199},[193,930,931],{"style":253}," Response",[193,933,767],{"style":206},[193,935,936,939,941,943,945,947,949,951,953,955,957,959,961,963,965,967,969,971,974,976,978,980,982,984,986,988,991,993,995,997],{"class":195,"style":196},[193,937,938],{"style":199},"  :",[193,940,334],{"style":206},[193,942,130],{"style":281},[193,944,285],{"style":199},[193,946,903],{"style":253},[193,948,906],{"style":206},[193,950,815],{"style":199},[193,952,903],{"style":253},[193,954,913],{"style":206},[193,956,916],{"style":281},[193,958,285],{"style":199},[193,960,921],{"style":266},[193,962,685],{"style":206},[193,964,926],{"style":281},[193,966,285],{"style":199},[193,968,931],{"style":253},[193,970,356],{"style":206},[193,972,973],{"style":199},"|",[193,975,334],{"style":206},[193,977,130],{"style":281},[193,979,285],{"style":199},[193,981,921],{"style":266},[193,983,685],{"style":206},[193,985,916],{"style":281},[193,987,285],{"style":199},[193,989,990],{"style":206}," {}; ",[193,992,926],{"style":281},[193,994,285],{"style":199},[193,996,931],{"style":253},[193,998,767],{"style":206},[193,1000],{"class":195,"style":196},[193,1002,1003],{"class":195,"style":196},[193,1004,1006],{"style":1005},"color:#6A737D;--shiki-dark:#6A737D","\u002F\u002F Only needed by the query plugins: what a failed hook rejects with.",[193,1008,1009,1011,1013,1016,1018,1021,1023,1025,1027,1029,1032,1034,1036,1038,1040,1043],{"class":195,"style":196},[193,1010,247],{"style":199},[193,1012,203],{"style":199},[193,1014,1015],{"style":253}," ResponseErrorConfig",[193,1017,257],{"style":206},[193,1019,1020],{"style":253},"TError",[193,1022,270],{"style":199},[193,1024,644],{"style":266},[193,1026,801],{"style":206},[193,1028,359],{"style":199},[193,1030,1031],{"style":253}," Error",[193,1033,840],{"style":199},[193,1035,334],{"style":206},[193,1037,510],{"style":281},[193,1039,604],{"style":199},[193,1041,1042],{"style":253}," TError",[193,1044,767],{"style":206},[193,1046],{"class":195,"style":196},[193,1048,1049],{"class":195,"style":196},[193,1050,1051],{"style":1005},"\u002F\u002F Set this to your API host. `new URL()` needs an absolute URL.",[193,1053,1054,1056,1059,1062,1064,1067,1070],{"class":195,"style":196},[193,1055,247],{"style":199},[193,1057,1058],{"style":199}," const",[193,1060,1061],{"style":266}," settings",[193,1063,270],{"style":199},[193,1065,1066],{"style":206}," { baseURL: ",[193,1068,1069],{"style":213},"'https:\u002F\u002Fpetstore3.swagger.io\u002Fapi\u002Fv3'",[193,1071,767],{"style":206},[193,1073],{"class":195,"style":196},[193,1075,1076,1078,1081,1083,1085,1088,1090,1092,1094],{"class":195,"style":196},[193,1077,247],{"style":199},[193,1079,1080],{"style":199}," async",[193,1082,250],{"style":199},[193,1084,717],{"style":253},[193,1086,1087],{"style":206},"(",[193,1089,353],{"style":281},[193,1091,285],{"style":199},[193,1093,540],{"style":253},[193,1095,1096],{"style":206},") {",[193,1098,1099,1101,1104,1106,1109,1111,1114,1116,1119,1121,1123,1125,1127],{"class":195,"style":196},[193,1100,331],{"style":199},[193,1102,1103],{"style":266}," path",[193,1105,285],{"style":199},[193,1107,1108],{"style":253}," Record",[193,1110,257],{"style":206},[193,1112,1113],{"style":266},"string",[193,1115,112],{"style":206},[193,1117,1118],{"style":266},"unknown",[193,1120,801],{"style":206},[193,1122,359],{"style":199},[193,1124,334],{"style":206},[193,1126,350],{"style":199},[193,1128,1129],{"style":206},"config.path }",[193,1131,1132,1134,1137,1139,1142,1145,1148,1150,1153,1156,1159,1162,1164,1167,1171,1174,1177,1179,1181,1184,1186,1189,1192,1195,1197,1200,1203,1206,1209,1211,1214],{"class":195,"style":196},[193,1133,331],{"style":199},[193,1135,1136],{"style":266}," url",[193,1138,270],{"style":199},[193,1140,1141],{"style":199}," new",[193,1143,1144],{"style":253}," URL",[193,1146,1147],{"style":206},"((config.baseURL ",[193,1149,441],{"style":199},[193,1151,1152],{"style":206}," settings.baseURL) ",[193,1154,1155],{"style":199},"+",[193,1157,1158],{"style":206}," config.url.",[193,1160,1161],{"style":253},"replace",[193,1163,1087],{"style":206},[193,1165,1166],{"style":213},"\u002F",[193,1168,1170],{"style":1169},"color:#22863A;--shiki-light-font-weight:bold;--shiki-dark:#85E89D;--shiki-dark-font-weight:bold","\\{",[193,1172,1087],{"style":1173},"color:#032F62;--shiki-dark:#DBEDFF",[193,1175,1176],{"style":266},"\\w",[193,1178,1155],{"style":199},[193,1180,305],{"style":1173},[193,1182,1183],{"style":1169},"\\}",[193,1185,1166],{"style":213},[193,1187,1188],{"style":199},"g",[193,1190,1191],{"style":206},", (",[193,1193,1194],{"style":281},"_",[193,1196,112],{"style":206},[193,1198,1199],{"style":281},"key",[193,1201,1202],{"style":206},") ",[193,1204,1205],{"style":199},"=>",[193,1207,1208],{"style":253}," encodeURIComponent",[193,1210,1087],{"style":206},[193,1212,1213],{"style":253},"String",[193,1215,1216],{"style":206},"(path[key]))))",[193,1218],{"class":195,"style":196},[193,1220,1221,1223,1226,1228,1231,1234],{"class":195,"style":196},[193,1222,331],{"style":199},[193,1224,1225],{"style":266}," response",[193,1227,270],{"style":199},[193,1229,1230],{"style":199}," await",[193,1232,1233],{"style":253}," fetch",[193,1235,1236],{"style":206},"(url, {",[193,1238,1239],{"class":195,"style":196},[193,1240,1241],{"style":206},"    method: config.method,",[193,1243,1244,1247,1249,1251,1253,1255,1257,1259],{"class":195,"style":196},[193,1245,1246],{"style":206},"    headers: config.headers ",[193,1248,453],{"style":199},[193,1250,1108],{"style":253},[193,1252,257],{"style":206},[193,1254,1113],{"style":266},[193,1256,112],{"style":206},[193,1258,1113],{"style":266},[193,1260,300],{"style":206},[193,1262,1263,1266,1269,1271,1274,1276,1279,1282,1284,1287],{"class":195,"style":196},[193,1264,1265],{"style":206},"    body: config.body ",[193,1267,1268],{"style":199},"===",[193,1270,921],{"style":266},[193,1272,1273],{"style":199}," ?",[193,1275,921],{"style":266},[193,1277,1278],{"style":199}," :",[193,1280,1281],{"style":266}," JSON",[193,1283,65],{"style":206},[193,1285,1286],{"style":253},"stringify",[193,1288,1289],{"style":206},"(config.body),",[193,1291,1292],{"class":195,"style":196},[193,1293,1294],{"style":206},"    signal: config.signal,",[193,1296,1297],{"class":195,"style":196},[193,1298,1299],{"style":206},"  })",[193,1301,1302,1304,1307,1309,1311,1314,1317,1320,1323,1326,1328,1330],{"class":195,"style":196},[193,1303,331],{"style":199},[193,1305,1306],{"style":266}," body",[193,1308,270],{"style":199},[193,1310,1230],{"style":199},[193,1312,1313],{"style":206}," response.",[193,1315,1316],{"style":253},"json",[193,1318,1319],{"style":206},"().",[193,1321,1322],{"style":253},"catch",[193,1324,1325],{"style":206},"(() ",[193,1327,1205],{"style":199},[193,1329,921],{"style":266},[193,1331,305],{"style":206},[193,1333],{"class":195,"style":196},[193,1335,1336,1339,1342,1345,1348,1351],{"class":195,"style":196},[193,1337,1338],{"style":199},"  if",[193,1340,1341],{"style":206}," (response.ok) ",[193,1343,1344],{"style":199},"return",[193,1346,1347],{"style":206}," { data: body, error: ",[193,1349,1350],{"style":266},"undefined",[193,1352,1353],{"style":206},", response }",[193,1355,1356,1358,1361,1363,1365,1367,1370,1372,1374,1376,1379,1381,1383,1386,1389],{"class":195,"style":196},[193,1357,1338],{"style":199},[193,1359,1360],{"style":206}," (config.throwOnError ",[193,1362,441],{"style":199},[193,1364,273],{"style":266},[193,1366,1202],{"style":206},[193,1368,1369],{"style":199},"throw",[193,1371,1141],{"style":199},[193,1373,1031],{"style":253},[193,1375,1087],{"style":206},[193,1377,1378],{"style":213},"`Request failed with status ${",[193,1380,926],{"style":206},[193,1382,65],{"style":213},[193,1384,1385],{"style":206},"status",[193,1387,1388],{"style":213},"}`",[193,1390,305],{"style":206},[193,1392,1393,1395,1398,1400,1403,1405],{"class":195,"style":196},[193,1394,369],{"style":199},[193,1396,1397],{"style":206}," { data: ",[193,1399,1350],{"style":266},[193,1401,1402],{"style":206},", error: body ",[193,1404,441],{"style":199},[193,1406,1407],{"style":206}," { status: response.status }, response }",[193,1409,1410],{"class":195,"style":196},[193,1411,475],{"style":206},[10,1413,1414,1415,1419],{},"The ",[14,1416,1418],{"href":1417},"https:\u002F\u002Fgithub.com\u002Fkubb-labs\u002Fplugins\u002Ftree\u002Fmain\u002Fexamples\u002Fclient","example project"," has a fuller version with a base URL setter, query handling, and an async auth hook. The types in this sketch are minimal. Add status-aware response types when you need them.",[1421,1422,1424,1425,1427],"blockquote",{"as":1423},"tip","Kubb does not depend on retries, interceptors, or request signing. Add them to ",[18,1426,56],{}," when you need them.",{"title":1429,"searchDepth":1430,"depth":1430,"links":1431},"",5,[1432,1434,1435],{"id":25,"depth":1433,"text":26},2,{"id":181,"depth":1433,"text":182},{"id":517,"depth":1433,"text":518},"md",{},{},true,null,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fwrite-your-client",{"title":5},{"loc":1441},"extensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fwrite-your-client","mhfi83lnDoJIr9eJ-hbKIq4a7n4kWBfQe_SNH5vy8rA",false,1792842174198]