[{"data":1,"prerenderedAt":1415},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1414,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations.md",{},"Call operations",{"type":8,"value":9,"toc":1398},"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,942,946,952,1041,1052,1056,1061,1077,1080,1096,1149,1166,1357,1374,1378],[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,930,931,935,936,938,939,941],{},"The client sets ",[23,928,929],{},"retry: 0",", so a call is sent once, where Ky's own default is 2. See ",[244,932,934],{"href":933},"#retry-a-call","Retry a call"," to turn it on. Ky's ",[23,937,817],{}," default stays: 10 seconds to get the response headers, or ",[23,940,654],{}," to wait without a limit.",[15,943,945],{"id":944},"build-a-url-without-sending","Build a URL without sending",[11,947,948,951],{},[23,949,950],{},"client.getUrl"," builds the URL a request would use, with the same base URL and serialization:",[42,953,955],{"language":44,"code":954,"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,956,957,77,973,77,975,77,1036],{"class":49},[51,958,959,961,963,966,968,970],{"class":53,"style":54},[51,960,58],{"style":57},[51,962,62],{"style":61},[51,964,965],{"style":65},"client ",[51,967,69],{"style":61},[51,969,72],{"style":57},[51,971,972],{"style":75},"'.\u002Fgen\u002F.kubb\u002Fclient'",[51,974],{"class":53,"style":54},[51,976,977,979,982,984,987,989,992,994,997,999,1002,1004,1006,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026,1029,1031,1034],{"class":53,"style":54},[51,978,100],{"style":57},[51,980,981],{"style":65},"url ",[51,983,110],{"style":57},[51,985,986],{"style":65},"client",[51,988,281],{"style":57},[51,990,991],{"style":116},"getUrl",[51,993,120],{"style":61},[51,995,996],{"style":61},"url",[51,998,125],{"style":57},[51,1000,1001],{"style":75},"'\u002Fpets\u002F{petId}'",[51,1003,26],{"style":57},[51,1005,25],{"style":61},[51,1007,125],{"style":57},[51,1009,62],{"style":61},[51,1011,130],{"style":61},[51,1013,125],{"style":57},[51,1015,135],{"style":61},[51,1017,170],{"style":61},[51,1019,26],{"style":57},[51,1021,29],{"style":61},[51,1023,125],{"style":57},[51,1025,62],{"style":61},[51,1027,1028],{"style":61},"fields",[51,1030,125],{"style":57},[51,1032,1033],{"style":75},"'name' ",[51,1035,138],{"style":61},[51,1037,1038],{"class":53,"style":54},[51,1039,1040],{"style":143},"\u002F\u002F https:\u002F\u002Fpetstore.swagger.io\u002Fv2\u002Fpets\u002F1?fields=name",[11,1042,1043,1044,1048,1049,281],{},"Next, ",[244,1045,1047],{"href":1046},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ferror-handling","handle errors",", including ",[23,1050,1051],{},"throwOnError: false",[15,1053,1055],{"id":1054},"less-common-cases","Less common cases",[1057,1058,1060],"h3",{"id":1059},"path-parameter-casing","Path parameter casing",[11,1062,1063,1064,1068,1069,1072,1073,1076],{},"When you set ",[244,1065,1066],{"href":246},[23,1067,249],{},", the HTTP request stays the same, because path parameter names never reach the wire. The exception is the ",[23,1070,1071],{},"matrix"," style, which sends the name (",[23,1074,1075],{},";group-id=42","), so an operation with a matrix path parameter keeps its spec names.",[1057,1078,934],{"id":1079},"retry-a-call",[11,1081,1082,1083,1085,1086,1089,1090,828,1093,295],{},"Set Ky's ",[23,1084,814],{}," option to retry a network error, for every call or for one. Ky retries only the methods in ",[23,1087,1088],{},"retry.methods",", which leaves out ",[23,1091,1092],{},"POST",[23,1094,1095],{},"PATCH",[42,1097,1099],{"language":44,"code":1098,"class":46},"import { client } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({ options: { retry: { limit: 2 } } })",[23,1100,1101,77,1115,77,1117],{"class":49},[51,1102,1103,1105,1107,1109,1111,1113],{"class":53,"style":54},[51,1104,58],{"style":57},[51,1106,62],{"style":61},[51,1108,965],{"style":65},[51,1110,69],{"style":61},[51,1112,72],{"style":57},[51,1114,972],{"style":75},[51,1116],{"class":53,"style":54},[51,1118,1119,1121,1123,1126,1128,1130,1132,1134,1136,1138,1140,1142,1144,1147],{"class":53,"style":54},[51,1120,986],{"style":65},[51,1122,281],{"style":57},[51,1124,1125],{"style":116},"setConfig",[51,1127,120],{"style":61},[51,1129,805],{"style":61},[51,1131,125],{"style":57},[51,1133,62],{"style":61},[51,1135,814],{"style":61},[51,1137,125],{"style":57},[51,1139,62],{"style":61},[51,1141,884],{"style":61},[51,1143,125],{"style":57},[51,1145,1146],{"style":61},"2 ",[51,1148,892],{"style":61},[11,1150,1151,1153,1154,1157,1158,1161,1162,1165],{},[23,1152,814],{}," alone does not retry an error status such as ",[23,1155,1156],{},"503",", because Kubb reads the error response itself, and Ky only retries a status it throws on. To retry a status, return ",[23,1159,1160],{},"ky.retry()"," from an ",[23,1163,1164],{},"afterResponse"," hook, and stop at the limit so the call gets the last response:",[42,1167,1169],{"language":44,"code":1168,"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,1170,1171,77,1183,77,1197,77,1199,77,1210,77,1220,77,1242,77,1252,77,1337,77,1345,77,1353],{"class":49},[51,1172,1173,1175,1178,1180],{"class":53,"style":54},[51,1174,58],{"style":57},[51,1176,1177],{"style":65},"ky ",[51,1179,72],{"style":57},[51,1181,1182],{"style":75},"'ky'",[51,1184,1185,1187,1189,1191,1193,1195],{"class":53,"style":54},[51,1186,58],{"style":57},[51,1188,62],{"style":61},[51,1190,965],{"style":65},[51,1192,69],{"style":61},[51,1194,72],{"style":57},[51,1196,972],{"style":75},[51,1198],{"class":53,"style":54},[51,1200,1201,1203,1205,1207],{"class":53,"style":54},[51,1202,986],{"style":65},[51,1204,281],{"style":57},[51,1206,1125],{"style":116},[51,1208,1209],{"style":61},"({",[51,1211,1212,1214,1216,1218],{"class":53,"style":54},[51,1213,318],{"style":61},[51,1215,805],{"style":61},[51,1217,125],{"style":57},[51,1219,313],{"style":61},[51,1221,1222,1225,1227,1229,1231,1233,1235,1237,1239],{"class":53,"style":54},[51,1223,1224],{"style":61},"    ",[51,1226,814],{"style":61},[51,1228,125],{"style":57},[51,1230,62],{"style":61},[51,1232,884],{"style":61},[51,1234,125],{"style":57},[51,1236,1146],{"style":61},[51,1238,170],{"style":61},[51,1240,1241],{"style":57},",",[51,1243,1244,1246,1248,1250],{"class":53,"style":54},[51,1245,1224],{"style":57},[51,1247,820],{"style":61},[51,1249,125],{"style":57},[51,1251,313],{"style":61},[51,1253,1254,1257,1259,1261,1264,1266,1268,1271,1273,1276,1279,1282,1284,1286,1288,1290,1292,1295,1298,1301,1304,1306,1308,1310,1312,1315,1318,1321,1323,1325,1327,1329,1332,1335],{"class":53,"style":54},[51,1255,1256],{"style":61},"      ",[51,1258,1164],{"style":61},[51,1260,125],{"style":57},[51,1262,1263],{"style":61},"[({ ",[51,1265,412],{"style":65},[51,1267,26],{"style":57},[51,1269,1270],{"style":65},"retryCount",[51,1272,26],{"style":57},[51,1274,1275],{"style":65},"options ",[51,1277,1278],{"style":61},"}) ",[51,1280,1281],{"style":57},"=> ",[51,1283,483],{"style":61},[51,1285,412],{"style":65},[51,1287,281],{"style":57},[51,1289,520],{"style":61},[51,1291,523],{"style":57},[51,1293,1294],{"style":61},"503 ",[51,1296,1297],{"style":57},"&& ",[51,1299,1300],{"style":65},"retryCount ",[51,1302,1303],{"style":57},"\u003C ",[51,1305,805],{"style":65},[51,1307,281],{"style":57},[51,1309,814],{"style":61},[51,1311,281],{"style":57},[51,1313,1314],{"style":61},"limit ",[51,1316,1317],{"style":57},"? ",[51,1319,1320],{"style":65},"ky",[51,1322,281],{"style":57},[51,1324,814],{"style":116},[51,1326,228],{"style":61},[51,1328,125],{"style":57},[51,1330,1331],{"style":61},"undefined",[51,1333,1334],{"style":61},")]",[51,1336,1241],{"style":57},[51,1338,1339,1341,1343],{"class":53,"style":54},[51,1340,1224],{"style":57},[51,1342,170],{"style":61},[51,1344,1241],{"style":57},[51,1346,1347,1349,1351],{"class":53,"style":54},[51,1348,318],{"style":57},[51,1350,170],{"style":61},[51,1352,1241],{"style":57},[51,1354,1355],{"class":53,"style":54},[51,1356,740],{"style":61},[259,1358,1360,1361,1363,1364,1366,1367,1369,1370,1373],{"as":1359},"warning","",[23,1362,1160],{}," skips Ky's ",[23,1365,1088],{}," check, so this hook also resends a ",[23,1368,1092],{},". Check ",[23,1371,1372],{},"request.method"," in the hook when that is not safe.",[1057,1375,1377],{"id":1376},"trace-operations","TRACE operations",[11,1379,1380,1381,1384,1385,1388,1389,1392,1393,1397],{},"When the spec has a ",[23,1382,1383],{},"trace"," operation, Kubb generates a call for it, but Ky rejects the ",[23,1386,1387],{},"TRACE"," method. Use ",[23,1390,1391],{},"@kubb\u002Fplugin-axios"," or a ",[244,1394,1396],{"href":1395},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Ftransport","custom transport"," for it.",{"title":1360,"searchDepth":1399,"depth":1399,"links":1400},5,[1401,1403,1404,1405,1406,1407,1408],{"id":17,"depth":1402,"text":18},2,{"id":284,"depth":1402,"text":285},{"id":549,"depth":1402,"text":550},{"id":670,"depth":1402,"text":671},{"id":798,"depth":1402,"text":799},{"id":944,"depth":1402,"text":945},{"id":1054,"depth":1402,"text":1055,"children":1409},[1410,1412,1413],{"id":1059,"depth":1411,"text":1060},3,{"id":1079,"depth":1411,"text":934},{"id":1376,"depth":1411,"text":1377},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations",1795015653496]