[{"data":1,"prerenderedAt":495,"buildId":496},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fcalling-operations":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":494,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fcalling-operations.md",{},"Call operations",{"type":8,"value":9,"toc":484},"minimark",[10,19,185,206,284,298,303,318,442,449,453,457,467],[11,12,13,14,18],"p",{},"Call a generated function with one grouped options object. It returns your client's promise, shaped by your ",[15,16,17],"code",{},"RequestResult"," type.",[20,21,25],"pre",{"language":22,"code":23,"class":24},"typescript","import { addPet, getPetById } from '.\u002Fgen\u002Fclients'\n\nconst created = await addPet({ body: { name: 'Odie', photoUrls: [] } })\nconsole.log(created.data, created.response.status)\n\nconst pet = await getPetById({ path: { petId: 1 } })","highlights",[15,26,28,61,62,61,64,61,110,61,149,61,151],{"class":27},"language-typescript",[29,30,33,37,41,45,48,51,54,57],"span",{"class":31,"style":32},"line","display: inline",[29,34,36],{"style":35},"color:#d73a49;--hls-dark:#f97583","import ",[29,38,40],{"style":39},"color:#005cc5;--hls-dark:#79b8ff","{ ",[29,42,44],{"style":43},"color:#24292e;--hls-dark:#e1e4e8","addPet",[29,46,47],{"style":35},", ",[29,49,50],{"style":43},"getPetById ",[29,52,53],{"style":39},"} ",[29,55,56],{"style":35},"from ",[29,58,60],{"style":59},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002Fclients'","\n",[29,63],{"class":31,"style":32},[29,65,66,69,72,75,78,81,84,87,90,92,95,97,100,102,105,107],{"class":31,"style":32},[29,67,68],{"style":35},"const ",[29,70,71],{"style":43},"created ",[29,73,74],{"style":35},"= ",[29,76,77],{"style":35},"await ",[29,79,44],{"style":80},"color:#6f42c1;--hls-dark:#b392f0",[29,82,83],{"style":39},"({ ",[29,85,86],{"style":39},"body",[29,88,89],{"style":35},": ",[29,91,40],{"style":39},[29,93,94],{"style":39},"name",[29,96,89],{"style":35},[29,98,99],{"style":59},"'Odie'",[29,101,47],{"style":35},[29,103,104],{"style":39},"photoUrls",[29,106,89],{"style":35},[29,108,109],{"style":39},"[] } })",[29,111,112,115,118,121,124,127,129,132,134,136,138,141,143,146],{"class":31,"style":32},[29,113,114],{"style":43},"console",[29,116,117],{"style":35},".",[29,119,120],{"style":80},"log",[29,122,123],{"style":39},"(",[29,125,126],{"style":43},"created",[29,128,117],{"style":35},[29,130,131],{"style":39},"data",[29,133,47],{"style":35},[29,135,126],{"style":43},[29,137,117],{"style":35},[29,139,140],{"style":39},"response",[29,142,117],{"style":35},[29,144,145],{"style":39},"status",[29,147,148],{"style":39},")",[29,150],{"class":31,"style":32},[29,152,153,155,158,160,162,165,167,170,172,174,177,179,182],{"class":31,"style":32},[29,154,68],{"style":35},[29,156,157],{"style":43},"pet ",[29,159,74],{"style":35},[29,161,77],{"style":35},[29,163,164],{"style":80},"getPetById",[29,166,83],{"style":39},[29,168,169],{"style":39},"path",[29,171,89],{"style":35},[29,173,40],{"style":39},[29,175,176],{"style":39},"petId",[29,178,89],{"style":35},[29,180,181],{"style":39},"1 ",[29,183,184],{"style":39},"} })",[11,186,187,188,195,196,198,199,202,203,117],{},"The examples set ",[189,190,192],"a",{"href":191},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[15,193,194],{},"integerType: 'number'"," on the adapter. Without it, ",[15,197,176],{}," is a ",[15,200,201],{},"bigint"," and takes ",[15,204,205],{},"1n",[207,208,209,222],"table",{},[210,211,212],"thead",{},[213,214,215,219],"tr",{},[216,217,218],"th",{},"Key",[216,220,221],{},"Holds",[223,224,225,246,263,273],"tbody",{},[213,226,227,243],{},[228,229,230,47,232,47,235,47,238,47,241],"td",{},[15,231,169],{},[15,233,234],{},"query",[15,236,237],{},"headers",[15,239,240],{},"cookies",[15,242,86],{},[228,244,245],{},"The request values, typed from the spec.",[213,247,248,253],{},[228,249,250],{},[15,251,252],{},"throwOnError",[228,254,255,256,262],{},"Overrides ",[189,257,259],{"href":258},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Foptions#throwonerrordefault",[15,260,261],{},"throwOnErrorDefault"," for this call.",[213,264,265,270],{},[228,266,267],{},[15,268,269],{},"client",[228,271,272],{},"Another client function for this call, such as a signed or per-tenant client.",[213,274,275,278],{},[228,276,277],{},"Any other key",[228,279,280,281,117],{},"Passed to your client as is, such as ",[15,282,283],{},"signal",[11,285,286,287,293,294,117],{},"Path keys keep their spec names unless you set ",[189,288,290],{"href":289},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#pathparamscasing",[15,291,292],{},"pathParamsCasing",". See ",[189,295,297],{"href":296},"#path-parameter-names","Path parameter names",[299,300,302],"h2",{"id":301},"handle-errors","Handle errors",[11,304,305,306,308,309,313,314,317],{},"Your client decides what ",[15,307,252],{}," does. With the ",[189,310,312],{"href":311},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fwrite-your-client#write-the-client","client from scratch",", a non-2xx status throws, and ",[15,315,316],{},"throwOnError: false"," returns the error as a value:",[20,319,321],{"language":22,"code":320,"class":24},"const result = await getPetById({ path: { petId: 1 }, throwOnError: false })\n\nif (result.error === undefined) console.log('pet', result.data)\nelse console.log('failed', result.response.status)",[15,322,323,61,365,61,367,61,412],{"class":27},[29,324,325,327,330,332,334,336,338,340,342,344,346,348,350,353,355,357,359,362],{"class":31,"style":32},[29,326,68],{"style":35},[29,328,329],{"style":43},"result ",[29,331,74],{"style":35},[29,333,77],{"style":35},[29,335,164],{"style":80},[29,337,83],{"style":39},[29,339,169],{"style":39},[29,341,89],{"style":35},[29,343,40],{"style":39},[29,345,176],{"style":39},[29,347,89],{"style":35},[29,349,181],{"style":39},[29,351,352],{"style":39},"}",[29,354,47],{"style":35},[29,356,252],{"style":39},[29,358,89],{"style":35},[29,360,361],{"style":39},"false ",[29,363,364],{"style":39},"})",[29,366],{"class":31,"style":32},[29,368,369,372,374,377,379,382,385,388,391,393,395,397,399,402,404,406,408,410],{"class":31,"style":32},[29,370,371],{"style":35},"if ",[29,373,123],{"style":39},[29,375,376],{"style":43},"result",[29,378,117],{"style":35},[29,380,381],{"style":39},"error ",[29,383,384],{"style":35},"=== ",[29,386,387],{"style":39},"undefined",[29,389,390],{"style":39},") ",[29,392,114],{"style":43},[29,394,117],{"style":35},[29,396,120],{"style":80},[29,398,123],{"style":39},[29,400,401],{"style":59},"'pet'",[29,403,47],{"style":35},[29,405,376],{"style":43},[29,407,117],{"style":35},[29,409,131],{"style":39},[29,411,148],{"style":39},[29,413,414,417,419,421,423,425,428,430,432,434,436,438,440],{"class":31,"style":32},[29,415,416],{"style":35},"else ",[29,418,114],{"style":43},[29,420,117],{"style":35},[29,422,120],{"style":80},[29,424,123],{"style":39},[29,426,427],{"style":59},"'failed'",[29,429,47],{"style":35},[29,431,376],{"style":43},[29,433,117],{"style":35},[29,435,140],{"style":39},[29,437,117],{"style":35},[29,439,145],{"style":39},[29,441,148],{"style":39},[11,443,444,445,117],{},"Next, ",[189,446,448],{"href":447},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fvalidate-requests-and-responses","validate requests and responses",[299,450,452],{"id":451},"less-common-cases","Less common cases",[454,455,297],"h3",{"id":456},"path-parameter-names",[11,458,459,460,463,464,117],{},"When the spec names a path parameter in kebab or snake case, such as ",[15,461,462],{},"{pet-id}",", the path key keeps that name: pass ",[15,465,466],{},"path: { 'pet-id': 1 }",[11,468,469,470,475,476,479,480,483],{},"Set ",[189,471,472],{"href":289},[15,473,474],{},"pathParamsCasing: 'camelcase'"," on the adapter (",[15,477,478],{},"@kubb\u002Fadapter-oas"," 5.20.0 or later) to pass ",[15,481,482],{},"path: { petId: 1 }"," instead. The HTTP request stays the same.",{"title":485,"searchDepth":486,"depth":486,"links":487},"",5,[488,490],{"id":301,"depth":489,"text":302},2,{"id":451,"depth":489,"text":452,"children":491},[492],{"id":456,"depth":493,"text":297},3,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-client\u002Fguides\u002Fcalling-operations",1795727683742,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]