[{"data":1,"prerenderedAt":1436,"buildId":1437},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1435,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations.md",{},"Call operations",{"type":8,"value":9,"toc":1419},"minimark",[10,14,19,41,232,258,282,286,296,425,435,547,551,558,605,658,668,672,688,796,800,832,893,924,950,954,960,1049,1060,1064,1069,1085,1089,1101,1117,1170,1187,1378,1395,1399],[11,12,13],"p",{},"Call a generated function with grouped request options, read the typed result, and pass content types or Ky options for one call.",[15,16,18],"h2",{"id":17},"call-an-operation","Call an operation",[11,20,21,22,26,27,26,30,26,33,36,37,40],{},"Pass each request part under its own key: ",[23,24,25],"code",{},"path",", ",[23,28,29],{},"query",[23,31,32],{},"headers",[23,34,35],{},"cookies",", or ",[23,38,39],{},"body",". A key exists only when the operation declares that part:",[42,43,47],"pre",{"language":44,"code":45,"class":46},"typescript","import { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\nimport { updatePet } from '.\u002Fgen\u002Fclients\u002FupdatePet'\n\nconst { data } = await getPetById({ path: { petId: 1 } })\n\u002F\u002F ^ the parsed pet, typed from the 200 response\n\nawait updatePet({ path: { petId: 1 }, headers: { 'X-Request-ID': 'r-1' }, body: { name: 'Rex', status: 'sold' } })\n\nawait getStatus() \u002F\u002F no required parameters, no argument","highlights",[23,48,50,77,78,77,94,77,96,77,139,77,145,77,147,77,217,77,219],{"class":49},"language-typescript",[51,52,55,59,63,67,70,73],"span",{"class":53,"style":54},"line","display: inline",[51,56,58],{"style":57},"color:#d73a49;--hls-dark:#f97583","import ",[51,60,62],{"style":61},"color:#005cc5;--hls-dark:#79b8ff","{ ",[51,64,66],{"style":65},"color:#24292e;--hls-dark:#e1e4e8","getPetById ",[51,68,69],{"style":61},"} ",[51,71,72],{"style":57},"from ",[51,74,76],{"style":75},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002Fclients\u002FgetPetById'","\n",[51,79,80,82,84,87,89,91],{"class":53,"style":54},[51,81,58],{"style":57},[51,83,62],{"style":61},[51,85,86],{"style":65},"updatePet ",[51,88,69],{"style":61},[51,90,72],{"style":57},[51,92,93],{"style":75},"'.\u002Fgen\u002Fclients\u002FupdatePet'",[51,95],{"class":53,"style":54},[51,97,98,101,103,106,108,111,114,118,121,123,126,128,131,133,136],{"class":53,"style":54},[51,99,100],{"style":57},"const ",[51,102,62],{"style":61},[51,104,105],{"style":65},"data ",[51,107,69],{"style":61},[51,109,110],{"style":57},"= ",[51,112,113],{"style":57},"await ",[51,115,117],{"style":116},"color:#6f42c1;--hls-dark:#b392f0","getPetById",[51,119,120],{"style":61},"({ ",[51,122,25],{"style":61},[51,124,125],{"style":57},": ",[51,127,62],{"style":61},[51,129,130],{"style":61},"petId",[51,132,125],{"style":57},[51,134,135],{"style":61},"1 ",[51,137,138],{"style":61},"} })",[51,140,141],{"class":53,"style":54},[51,142,144],{"style":143},"color:#6a737d;--hls-dark:#6a737d","\u002F\u002F ^ the parsed pet, typed from the 200 response",[51,146],{"class":53,"style":54},[51,148,149,151,154,156,158,160,162,164,166,168,171,173,175,177,179,182,184,187,189,191,193,195,197,200,202,205,207,210,212,215],{"class":53,"style":54},[51,150,113],{"style":57},[51,152,153],{"style":116},"updatePet",[51,155,120],{"style":61},[51,157,25],{"style":61},[51,159,125],{"style":57},[51,161,62],{"style":61},[51,163,130],{"style":61},[51,165,125],{"style":57},[51,167,135],{"style":61},[51,169,170],{"style":61},"}",[51,172,26],{"style":57},[51,174,32],{"style":61},[51,176,125],{"style":57},[51,178,62],{"style":61},[51,180,181],{"style":75},"'X-Request-ID'",[51,183,125],{"style":57},[51,185,186],{"style":75},"'r-1' ",[51,188,170],{"style":61},[51,190,26],{"style":57},[51,192,39],{"style":61},[51,194,125],{"style":57},[51,196,62],{"style":61},[51,198,199],{"style":61},"name",[51,201,125],{"style":57},[51,203,204],{"style":75},"'Rex'",[51,206,26],{"style":57},[51,208,209],{"style":61},"status",[51,211,125],{"style":57},[51,213,214],{"style":75},"'sold' ",[51,216,138],{"style":61},[51,218],{"class":53,"style":54},[51,220,221,223,226,229],{"class":53,"style":54},[51,222,113],{"style":57},[51,224,225],{"style":116},"getStatus",[51,227,228],{"style":61},"() ",[51,230,231],{"style":143},"\u002F\u002F no required parameters, no argument",[11,233,234,235,238,239,242,243,250,251,254,255,257],{},"Path keys keep the spec's names, so ",[23,236,237],{},"{pet-id}"," takes ",[23,240,241],{},"path: { 'pet-id': 1 }",". Set ",[244,245,247],"a",{"href":246},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#pathparamscasing",[23,248,249],{},"pathParamsCasing: 'camelcase'"," on the adapter (",[23,252,253],{},"@kubb\u002Fadapter-oas"," 5.20.0 or later) to pass ",[23,256,130],{}," instead.",[259,260,262,263,269,270,273,274,277,278,281],"blockquote",{"as":261},"note","The examples set ",[244,264,266],{"href":265},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[23,267,268],{},"integerType: 'number'",". With the default ",[23,271,272],{},"bigint",", an ",[23,275,276],{},"int64"," id takes ",[23,279,280],{},"1n",".",[15,283,285],{"id":284},"read-the-result","Read the result",[11,287,288,289,292,293,295],{},"A call resolves to a ",[23,290,291],{},"RequestResult",", a union narrowed by the numeric ",[23,294,209],{},":",[42,297,299],{"language":44,"code":298,"class":46},"type RequestResult = {\n status: number\n data: TData \u002F\u002F the parsed success body, undefined on an error result\n error: TError \u002F\u002F the parsed error body, undefined on a success result\n contentType: string | undefined \u002F\u002F the response media type, without parameters\n headers: Headers \u002F\u002F the response headers\n request: Request \u002F\u002F rebuilt from the resolved request\n response: Response \u002F\u002F the native response\n}",[23,300,301,77,314,77,326,77,341,77,356,77,377,77,391,77,406,77,421],{"class":49},[51,302,303,306,309,311],{"class":53,"style":54},[51,304,305],{"style":57},"type ",[51,307,308],{"style":116},"RequestResult ",[51,310,110],{"style":57},[51,312,313],{"style":61},"{",[51,315,316,319,321,323],{"class":53,"style":54},[51,317,318],{"style":61}," ",[51,320,209],{"style":61},[51,322,125],{"style":65},[51,324,325],{"style":116},"number",[51,327,328,330,333,335,338],{"class":53,"style":54},[51,329,318],{"style":116},[51,331,332],{"style":65},"data",[51,334,125],{"style":65},[51,336,337],{"style":116},"TData ",[51,339,340],{"style":143},"\u002F\u002F the parsed success body, undefined on an error result",[51,342,343,345,348,350,353],{"class":53,"style":54},[51,344,318],{"style":143},[51,346,347],{"style":65},"error",[51,349,125],{"style":65},[51,351,352],{"style":116},"TError ",[51,354,355],{"style":143},"\u002F\u002F the parsed error body, undefined on a success result",[51,357,358,360,363,365,368,371,374],{"class":53,"style":54},[51,359,318],{"style":143},[51,361,362],{"style":65},"contentType",[51,364,125],{"style":65},[51,366,367],{"style":116},"string ",[51,369,370],{"style":57},"| ",[51,372,373],{"style":61},"undefined ",[51,375,376],{"style":143},"\u002F\u002F the response media type, without parameters",[51,378,379,381,383,385,388],{"class":53,"style":54},[51,380,318],{"style":143},[51,382,32],{"style":65},[51,384,125],{"style":65},[51,386,387],{"style":116},"Headers ",[51,389,390],{"style":143},"\u002F\u002F the response headers",[51,392,393,395,398,400,403],{"class":53,"style":54},[51,394,318],{"style":143},[51,396,397],{"style":65},"request",[51,399,125],{"style":65},[51,401,402],{"style":116},"Request ",[51,404,405],{"style":143},"\u002F\u002F rebuilt from the resolved request",[51,407,408,410,413,415,418],{"class":53,"style":54},[51,409,318],{"style":143},[51,411,412],{"style":65},"response",[51,414,125],{"style":65},[51,416,417],{"style":116},"Response ",[51,419,420],{"style":143},"\u002F\u002F the native response",[51,422,423],{"class":53,"style":54},[51,424,170],{"style":61},[11,426,427,428,431,432,434],{},"With the default ",[23,429,430],{},"throwOnError: true",", a resolved call is always a success. Narrow on ",[23,433,209],{}," when an operation has several success statuses:",[42,436,438],{"language":44,"code":437,"class":46},"const result = await getPetById({ path: { petId: 1 } })\n\nconsole.info(result.headers.get('x-ratelimit-remaining')) \u002F\u002F suggests the declared header names\nif (result.status === 200) console.info(result.data)",[23,439,440,77,469,77,471,77,507],{"class":49},[51,441,442,444,447,449,451,453,455,457,459,461,463,465,467],{"class":53,"style":54},[51,443,100],{"style":57},[51,445,446],{"style":65},"result ",[51,448,110],{"style":57},[51,450,113],{"style":57},[51,452,117],{"style":116},[51,454,120],{"style":61},[51,456,25],{"style":61},[51,458,125],{"style":57},[51,460,62],{"style":61},[51,462,130],{"style":61},[51,464,125],{"style":57},[51,466,135],{"style":61},[51,468,138],{"style":61},[51,470],{"class":53,"style":54},[51,472,473,476,478,481,484,487,489,491,493,496,498,501,504],{"class":53,"style":54},[51,474,475],{"style":65},"console",[51,477,281],{"style":57},[51,479,480],{"style":116},"info",[51,482,483],{"style":61},"(",[51,485,486],{"style":65},"result",[51,488,281],{"style":57},[51,490,32],{"style":61},[51,492,281],{"style":57},[51,494,495],{"style":116},"get",[51,497,483],{"style":61},[51,499,500],{"style":75},"'x-ratelimit-remaining'",[51,502,503],{"style":61},")) ",[51,505,506],{"style":143},"\u002F\u002F suggests the declared header names",[51,508,509,512,514,516,518,521,524,527,530,532,534,536,538,540,542,544],{"class":53,"style":54},[51,510,511],{"style":57},"if ",[51,513,483],{"style":61},[51,515,486],{"style":65},[51,517,281],{"style":57},[51,519,520],{"style":61},"status ",[51,522,523],{"style":57},"=== ",[51,525,526],{"style":61},"200",[51,528,529],{"style":61},") ",[51,531,475],{"style":65},[51,533,281],{"style":57},[51,535,480],{"style":116},[51,537,483],{"style":61},[51,539,486],{"style":65},[51,541,281],{"style":57},[51,543,332],{"style":61},[51,545,546],{"style":61},")",[15,548,550],{"id":549},"unwrap-the-success-body","Unwrap the success body",[11,552,553,554,557],{},"Call ",[23,555,556],{},".unwrap()"," to get only the success body:",[42,559,561],{"language":44,"code":560,"class":46},"const pet = await getPetById({ path: { petId: 1 } }).unwrap()\n\u002F\u002F ^ the parsed pet",[23,562,563,77,600],{"class":49},[51,564,565,567,570,572,574,576,578,580,582,584,586,588,590,592,594,597],{"class":53,"style":54},[51,566,100],{"style":57},[51,568,569],{"style":65},"pet ",[51,571,110],{"style":57},[51,573,113],{"style":57},[51,575,117],{"style":116},[51,577,120],{"style":61},[51,579,25],{"style":61},[51,581,125],{"style":57},[51,583,62],{"style":61},[51,585,130],{"style":61},[51,587,125],{"style":57},[51,589,135],{"style":61},[51,591,138],{"style":61},[51,593,281],{"style":57},[51,595,596],{"style":116},"unwrap",[51,598,599],{"style":61},"()",[51,601,602],{"class":53,"style":54},[51,603,604],{"style":143},"\u002F\u002F ^ the parsed pet",[606,607,608,625],"table",{},[609,610,611],"thead",{},[612,613,614,620],"tr",{},[615,616,617],"th",{},[23,618,619],{},"throwOnError",[615,621,622,623],{},"A non-2xx response makes ",[23,624,556],{},[626,627,628,648],"tbody",{},[612,629,630,637],{},[631,632,633,636],"td",{},[23,634,635],{},"true"," (default)",[631,638,639,640,643,644,647],{},"throw a ",[23,641,642],{},"ResponseError",", as a plain ",[23,645,646],{},"await"," does.",[612,649,650,655],{},[631,651,652],{},[23,653,654],{},"false",[631,656,657],{},"reject with the parsed error body.",[11,659,660,661,667],{},"To get the body from every call, set ",[244,662,664],{"href":663},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Foptions#returntype",[23,665,666],{},"returnType: 'data'"," on the plugin.",[15,669,671],{"id":670},"set-the-content-type","Set the content type",[11,673,674,675,677,678,681,682,684,685,295],{},"When an operation accepts or returns several content types, set ",[23,676,362],{}," on the call. A string sets ",[23,679,680],{},"Content-Type",", and ",[23,683,412],{}," sets ",[23,686,687],{},"Accept",[689,690,691,741],"code-group",{},[42,692,695],{"language":44,"filename":693,"code":694,"class":46},"Request only","await uploadAvatar({ path: { petId: 1 }, body: avatarBlob, contentType: 'image\u002Fpng' })",[23,696,697],{"class":49},[51,698,699,701,704,706,708,710,712,714,716,718,720,722,724,726,729,731,733,735,738],{"class":53,"style":54},[51,700,113],{"style":57},[51,702,703],{"style":116},"uploadAvatar",[51,705,120],{"style":61},[51,707,25],{"style":61},[51,709,125],{"style":57},[51,711,62],{"style":61},[51,713,130],{"style":61},[51,715,125],{"style":57},[51,717,135],{"style":61},[51,719,170],{"style":61},[51,721,26],{"style":57},[51,723,39],{"style":61},[51,725,125],{"style":57},[51,727,728],{"style":65},"avatarBlob",[51,730,26],{"style":57},[51,732,362],{"style":61},[51,734,125],{"style":57},[51,736,737],{"style":75},"'image\u002Fpng' ",[51,739,740],{"style":61},"})",[42,742,745],{"language":44,"filename":743,"code":744,"class":46},"Request and Accept","await getPet({ path: { petId: 1 }, contentType: { request: 'application\u002Fjson', response: 'application\u002Fxml' } })",[23,746,747],{"class":49},[51,748,749,751,754,756,758,760,762,764,766,768,770,772,774,776,778,780,782,785,787,789,791,794],{"class":53,"style":54},[51,750,113],{"style":57},[51,752,753],{"style":116},"getPet",[51,755,120],{"style":61},[51,757,25],{"style":61},[51,759,125],{"style":57},[51,761,62],{"style":61},[51,763,130],{"style":61},[51,765,125],{"style":57},[51,767,135],{"style":61},[51,769,170],{"style":61},[51,771,26],{"style":57},[51,773,362],{"style":61},[51,775,125],{"style":57},[51,777,62],{"style":61},[51,779,397],{"style":61},[51,781,125],{"style":57},[51,783,784],{"style":75},"'application\u002Fjson'",[51,786,26],{"style":57},[51,788,412],{"style":61},[51,790,125],{"style":57},[51,792,793],{"style":75},"'application\u002Fxml' ",[51,795,138],{"style":61},[15,797,799],{"id":798},"pass-ky-options","Pass Ky options",[11,801,802,803,806,807,811,812,26,815,681,818,36,821,824,825,828,829,295],{},"Pass ",[23,804,805],{},"options"," for ",[244,808,810],{"href":809},"https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fky#options","Ky options"," such as ",[23,813,814],{},"retry",[23,816,817],{},"timeout",[23,819,820],{},"hooks",[23,822,823],{},"fetch"," settings such as ",[23,826,827],{},"cache"," and ",[23,830,831],{},"redirect",[42,833,835],{"language":44,"code":834,"class":46},"await getPetById({ path: { petId: 1 }, options: { timeout: 5000, retry: { limit: 3 } } })",[23,836,837],{"class":49},[51,838,839,841,843,845,847,849,851,853,855,857,859,861,863,865,867,869,871,874,876,878,880,882,885,887,890],{"class":53,"style":54},[51,840,113],{"style":57},[51,842,117],{"style":116},[51,844,120],{"style":61},[51,846,25],{"style":61},[51,848,125],{"style":57},[51,850,62],{"style":61},[51,852,130],{"style":61},[51,854,125],{"style":57},[51,856,135],{"style":61},[51,858,170],{"style":61},[51,860,26],{"style":57},[51,862,805],{"style":61},[51,864,125],{"style":57},[51,866,62],{"style":61},[51,868,817],{"style":61},[51,870,125],{"style":57},[51,872,873],{"style":61},"5000",[51,875,26],{"style":57},[51,877,814],{"style":61},[51,879,125],{"style":57},[51,881,62],{"style":61},[51,883,884],{"style":61},"limit",[51,886,125],{"style":57},[51,888,889],{"style":61},"3 ",[51,891,892],{"style":61},"} } })",[11,894,895,898,899,902,903,905,906,26,909,36,912,915,916,26,918,681,921,923],{},[23,896,897],{},"client.setConfig({ options })"," sets shared defaults, and per-call options win. Kubb sets the method, headers, body, and signal over them, and sets ",[23,900,901],{},"throwHttpErrors: false"," to keep control of status handling. ",[23,904,805],{}," does not take ",[23,907,908],{},"json",[23,910,911],{},"prefix",[23,913,914],{},"searchParams",", because Kubb builds the body and the URL: pass ",[23,917,39],{},[23,919,920],{},"baseURL",[23,922,29],{}," on the call.",[11,925,926,927,929,930,933,934,36,939,943,944,946,947,949],{},"The client sets Ky's ",[23,928,814],{}," to ",[23,931,932],{},"0",", so a call is sent once, where Ky's own default is 2. To retry, set the client's ",[244,935,937],{"href":936},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fconfigure-requests#retry-a-failed-call",[23,938,814],{},[244,940,942],{"href":941},"#retry-with-the-ky-option","Ky's own option",". Ky's ",[23,945,817],{}," default stays: 10 seconds to get the response headers, or ",[23,948,654],{}," to wait without a limit.",[15,951,953],{"id":952},"build-a-url-without-sending","Build a URL without sending",[11,955,956,959],{},[23,957,958],{},"client.getUrl"," builds the URL a request would use, with the same base URL and serialization:",[42,961,963],{"language":44,"code":962,"class":46},"import { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nconst url = client.getUrl({ url: '\u002Fpets\u002F{petId}', path: { petId: 1 }, query: { fields: 'name' } })\n\u002F\u002F https:\u002F\u002Fpetstore.swagger.io\u002Fv2\u002Fpets\u002F1?fields=name",[23,964,965,77,981,77,983,77,1044],{"class":49},[51,966,967,969,971,974,976,978],{"class":53,"style":54},[51,968,58],{"style":57},[51,970,62],{"style":61},[51,972,973],{"style":65},"client ",[51,975,69],{"style":61},[51,977,72],{"style":57},[51,979,980],{"style":75},"'.\u002Fgen\u002F.kubb\u002Fclient'",[51,982],{"class":53,"style":54},[51,984,985,987,990,992,995,997,1000,1002,1005,1007,1010,1012,1014,1016,1018,1020,1022,1024,1026,1028,1030,1032,1034,1037,1039,1042],{"class":53,"style":54},[51,986,100],{"style":57},[51,988,989],{"style":65},"url ",[51,991,110],{"style":57},[51,993,994],{"style":65},"client",[51,996,281],{"style":57},[51,998,999],{"style":116},"getUrl",[51,1001,120],{"style":61},[51,1003,1004],{"style":61},"url",[51,1006,125],{"style":57},[51,1008,1009],{"style":75},"'\u002Fpets\u002F{petId}'",[51,1011,26],{"style":57},[51,1013,25],{"style":61},[51,1015,125],{"style":57},[51,1017,62],{"style":61},[51,1019,130],{"style":61},[51,1021,125],{"style":57},[51,1023,135],{"style":61},[51,1025,170],{"style":61},[51,1027,26],{"style":57},[51,1029,29],{"style":61},[51,1031,125],{"style":57},[51,1033,62],{"style":61},[51,1035,1036],{"style":61},"fields",[51,1038,125],{"style":57},[51,1040,1041],{"style":75},"'name' ",[51,1043,138],{"style":61},[51,1045,1046],{"class":53,"style":54},[51,1047,1048],{"style":143},"\u002F\u002F https:\u002F\u002Fpetstore.swagger.io\u002Fv2\u002Fpets\u002F1?fields=name",[11,1050,1051,1052,1056,1057,281],{},"Next, ",[244,1053,1055],{"href":1054},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling","handle errors",", including ",[23,1058,1059],{},"throwOnError: false",[15,1061,1063],{"id":1062},"less-common-cases","Less common cases",[1065,1066,1068],"h3",{"id":1067},"path-parameter-casing","Path parameter casing",[11,1070,1071,1072,1076,1077,1080,1081,1084],{},"When you set ",[244,1073,1074],{"href":246},[23,1075,249],{},", the HTTP request stays the same, because path parameter names never reach the wire. The exception is the ",[23,1078,1079],{},"matrix"," style, which sends the name (",[23,1082,1083],{},";group-id=42","), so an operation with a matrix path parameter keeps its spec names.",[1065,1086,1088],{"id":1087},"retry-with-the-ky-option","Retry with the Ky option",[11,1090,1091,1092,1096,1097,929,1099,281],{},"Prefer the client's ",[244,1093,1094],{"href":936},[23,1095,814],{},", which also retries an error status. A call with it on sets Ky's ",[23,1098,814],{},[23,1100,932],{},[11,1102,1103,1104,1106,1107,1110,1111,828,1114,295],{},"Set Ky's ",[23,1105,814],{}," option to retry a network error, for every call or for one. Ky retries only the methods in ",[23,1108,1109],{},"retry.methods",", which leaves out ",[23,1112,1113],{},"POST",[23,1115,1116],{},"PATCH",[42,1118,1120],{"language":44,"code":1119,"class":46},"import { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({ options: { retry: { limit: 2 } } })",[23,1121,1122,77,1136,77,1138],{"class":49},[51,1123,1124,1126,1128,1130,1132,1134],{"class":53,"style":54},[51,1125,58],{"style":57},[51,1127,62],{"style":61},[51,1129,973],{"style":65},[51,1131,69],{"style":61},[51,1133,72],{"style":57},[51,1135,980],{"style":75},[51,1137],{"class":53,"style":54},[51,1139,1140,1142,1144,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165,1168],{"class":53,"style":54},[51,1141,994],{"style":65},[51,1143,281],{"style":57},[51,1145,1146],{"style":116},"setConfig",[51,1148,120],{"style":61},[51,1150,805],{"style":61},[51,1152,125],{"style":57},[51,1154,62],{"style":61},[51,1156,814],{"style":61},[51,1158,125],{"style":57},[51,1160,62],{"style":61},[51,1162,884],{"style":61},[51,1164,125],{"style":57},[51,1166,1167],{"style":61},"2 ",[51,1169,892],{"style":61},[11,1171,1172,1174,1175,1178,1179,1182,1183,1186],{},[23,1173,814],{}," alone does not retry an error status such as ",[23,1176,1177],{},"503",", because Kubb reads the error response itself, and Ky only retries a status it throws on. To retry a status, return ",[23,1180,1181],{},"ky.retry()"," from an ",[23,1184,1185],{},"afterResponse"," hook, and stop at the limit so the call gets the last response:",[42,1188,1190],{"language":44,"code":1189,"class":46},"import ky from 'ky'\nimport { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({\n options: {\n retry: { limit: 2 },\n hooks: {\n afterResponse: [({ response, retryCount, options }) => (response.status === 503 && retryCount \u003C options.retry.limit ? ky.retry() : undefined)],\n },\n },\n})",[23,1191,1192,77,1204,77,1218,77,1220,77,1231,77,1241,77,1263,77,1273,77,1358,77,1366,77,1374],{"class":49},[51,1193,1194,1196,1199,1201],{"class":53,"style":54},[51,1195,58],{"style":57},[51,1197,1198],{"style":65},"ky ",[51,1200,72],{"style":57},[51,1202,1203],{"style":75},"'ky'",[51,1205,1206,1208,1210,1212,1214,1216],{"class":53,"style":54},[51,1207,58],{"style":57},[51,1209,62],{"style":61},[51,1211,973],{"style":65},[51,1213,69],{"style":61},[51,1215,72],{"style":57},[51,1217,980],{"style":75},[51,1219],{"class":53,"style":54},[51,1221,1222,1224,1226,1228],{"class":53,"style":54},[51,1223,994],{"style":65},[51,1225,281],{"style":57},[51,1227,1146],{"style":116},[51,1229,1230],{"style":61},"({",[51,1232,1233,1235,1237,1239],{"class":53,"style":54},[51,1234,318],{"style":61},[51,1236,805],{"style":61},[51,1238,125],{"style":57},[51,1240,313],{"style":61},[51,1242,1243,1246,1248,1250,1252,1254,1256,1258,1260],{"class":53,"style":54},[51,1244,1245],{"style":61}," ",[51,1247,814],{"style":61},[51,1249,125],{"style":57},[51,1251,62],{"style":61},[51,1253,884],{"style":61},[51,1255,125],{"style":57},[51,1257,1167],{"style":61},[51,1259,170],{"style":61},[51,1261,1262],{"style":57},",",[51,1264,1265,1267,1269,1271],{"class":53,"style":54},[51,1266,1245],{"style":57},[51,1268,820],{"style":61},[51,1270,125],{"style":57},[51,1272,313],{"style":61},[51,1274,1275,1278,1280,1282,1285,1287,1289,1292,1294,1297,1300,1303,1305,1307,1309,1311,1313,1316,1319,1322,1325,1327,1329,1331,1333,1336,1339,1342,1344,1346,1348,1350,1353,1356],{"class":53,"style":54},[51,1276,1277],{"style":61}," ",[51,1279,1185],{"style":61},[51,1281,125],{"style":57},[51,1283,1284],{"style":61},"[({ ",[51,1286,412],{"style":65},[51,1288,26],{"style":57},[51,1290,1291],{"style":65},"retryCount",[51,1293,26],{"style":57},[51,1295,1296],{"style":65},"options ",[51,1298,1299],{"style":61},"}) ",[51,1301,1302],{"style":57},"=> ",[51,1304,483],{"style":61},[51,1306,412],{"style":65},[51,1308,281],{"style":57},[51,1310,520],{"style":61},[51,1312,523],{"style":57},[51,1314,1315],{"style":61},"503 ",[51,1317,1318],{"style":57},"&& ",[51,1320,1321],{"style":65},"retryCount ",[51,1323,1324],{"style":57},"\u003C ",[51,1326,805],{"style":65},[51,1328,281],{"style":57},[51,1330,814],{"style":61},[51,1332,281],{"style":57},[51,1334,1335],{"style":61},"limit ",[51,1337,1338],{"style":57},"? ",[51,1340,1341],{"style":65},"ky",[51,1343,281],{"style":57},[51,1345,814],{"style":116},[51,1347,228],{"style":61},[51,1349,125],{"style":57},[51,1351,1352],{"style":61},"undefined",[51,1354,1355],{"style":61},")]",[51,1357,1262],{"style":57},[51,1359,1360,1362,1364],{"class":53,"style":54},[51,1361,1245],{"style":57},[51,1363,170],{"style":61},[51,1365,1262],{"style":57},[51,1367,1368,1370,1372],{"class":53,"style":54},[51,1369,318],{"style":57},[51,1371,170],{"style":61},[51,1373,1262],{"style":57},[51,1375,1376],{"class":53,"style":54},[51,1377,740],{"style":61},[259,1379,1381,1382,1384,1385,1387,1388,1390,1391,1394],{"as":1380},"warning","",[23,1383,1181],{}," skips Ky's ",[23,1386,1109],{}," check, so this hook also resends a ",[23,1389,1113],{},". Check ",[23,1392,1393],{},"request.method"," in the hook when that is not safe.",[1065,1396,1398],{"id":1397},"trace-operations","TRACE operations",[11,1400,1401,1402,1405,1406,1409,1410,1413,1414,1418],{},"When the spec has a ",[23,1403,1404],{},"trace"," operation, Kubb generates a call for it, but Ky rejects the ",[23,1407,1408],{},"TRACE"," method. Use ",[23,1411,1412],{},"@kubb\u002Fplugin-axios"," or a ",[244,1415,1417],{"href":1416},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ftransport","custom transport"," for it.",{"title":1381,"searchDepth":1420,"depth":1420,"links":1421},5,[1422,1424,1425,1426,1427,1428,1429],{"id":17,"depth":1423,"text":18},2,{"id":284,"depth":1423,"text":285},{"id":549,"depth":1423,"text":550},{"id":670,"depth":1423,"text":671},{"id":798,"depth":1423,"text":799},{"id":952,"depth":1423,"text":953},{"id":1062,"depth":1423,"text":1063,"children":1430},[1431,1433,1434],{"id":1067,"depth":1432,"text":1068},3,{"id":1087,"depth":1432,"text":1088},{"id":1397,"depth":1432,"text":1398},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations",1795727684882,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]