[{"data":1,"prerenderedAt":876},["ShallowReactive",2],{"docs:\u002Fdocs\u002Fclient":3,"i-lucide:moon":868,"i-lucide:github":872,"i-lucide:menu":874},{"id":4,"title":5,"body":6,"description":861,"extension":862,"meta":863,"navigation":162,"path":864,"seo":865,"stem":866,"__hash__":867},"docs\u002Fdocs\u002Fclient.md","Generated Client",{"type":7,"value":8,"toc":857},"minimark",[9,22,27,30,48,197,234,370,379,386,482,489,554,562,566,572,853],[10,11,12,13,17,18,21],"p",{},"Nuxt Endpoints generates ",[14,15,16],"code",{},"$endpoint"," and ",[14,19,20],{},"#endpoints"," types from discovered endpoint definitions.",[23,24,26],"h2",{"id":25},"client-calls","Client calls",[10,28,29],{},"The primary call uses the route path and HTTP method. The default call returns the success body. Request options are inferred from the endpoint request schemas, and the returned body follows the JSON wire representation of the endpoint response schema.",[10,31,32,33,36,37,40,41,43,44,47],{},"Response validation uses the schema output on the server before HTTP serialization. The client sees the parsed JSON value, so a schema output such as ",[14,34,35],{},"Date"," is typed as ",[14,38,39],{},"string"," on ",[14,42,16],{},", ",[14,45,46],{},"useEndpoint",", and Vue Query clients.",[49,50,55],"pre",{"className":51,"code":52,"language":53,"meta":54,"style":54},"language-vue shiki shiki-themes github-light-default github-dark-default","\u003Cscript setup lang=\"ts\">\nconst user = await $endpoint('\u002Fapi\u002Fusers\u002F:id', {\n  method: 'get',\n  params: { id: '123' },\n  query: { includePosts: true },\n})\n\nuser.id.toFixed()\nuser.name.toUpperCase()\n\u003C\u002Fscript>\n","vue","",[14,56,57,87,116,128,140,151,157,164,176,187],{"__ignoreMap":54},[58,59,62,66,70,74,77,80,84],"span",{"class":60,"line":61},"line",1,[58,63,65],{"class":64},"saQ_J","\u003C",[58,67,69],{"class":68},"snZHK","script",[58,71,73],{"class":72},"sOOdx"," setup",[58,75,76],{"class":72}," lang",[58,78,79],{"class":64},"=",[58,81,83],{"class":82},"sZItA","\"ts\"",[58,85,86],{"class":64},">\n",[58,88,90,94,97,100,103,107,110,113],{"class":60,"line":89},2,[58,91,93],{"class":92},"swxxe","const",[58,95,96],{"class":72}," user",[58,98,99],{"class":92}," =",[58,101,102],{"class":92}," await",[58,104,106],{"class":105},"s9HWX"," $endpoint",[58,108,109],{"class":64},"(",[58,111,112],{"class":82},"'\u002Fapi\u002Fusers\u002F:id'",[58,114,115],{"class":64},", {\n",[58,117,119,122,125],{"class":60,"line":118},3,[58,120,121],{"class":64},"  method: ",[58,123,124],{"class":82},"'get'",[58,126,127],{"class":64},",\n",[58,129,131,134,137],{"class":60,"line":130},4,[58,132,133],{"class":64},"  params: { id: ",[58,135,136],{"class":82},"'123'",[58,138,139],{"class":64}," },\n",[58,141,143,146,149],{"class":60,"line":142},5,[58,144,145],{"class":64},"  query: { includePosts: ",[58,147,148],{"class":72},"true",[58,150,139],{"class":64},[58,152,154],{"class":60,"line":153},6,[58,155,156],{"class":64},"})\n",[58,158,160],{"class":60,"line":159},7,[58,161,163],{"emptyLinePlaceholder":162},true,"\n",[58,165,167,170,173],{"class":60,"line":166},8,[58,168,169],{"class":64},"user.id.",[58,171,172],{"class":105},"toFixed",[58,174,175],{"class":64},"()\n",[58,177,179,182,185],{"class":60,"line":178},9,[58,180,181],{"class":64},"user.name.",[58,183,184],{"class":105},"toUpperCase",[58,186,175],{"class":64},[58,188,190,193,195],{"class":60,"line":189},10,[58,191,192],{"class":64},"\u003C\u002F",[58,194,69],{"class":68},[58,196,86],{"class":64},[10,198,199,200,202,203,43,206,43,209,43,212,215,216,219,220,43,223,43,226,229,230,233],{},"Use ",[14,201,46],{}," when the same typed call should be managed as Nuxt async data.\nIt forwards Nuxt async-data options such as ",[14,204,205],{},"key",[14,207,208],{},"lazy",[14,210,211],{},"server",[14,213,214],{},"watch",", and\n",[14,217,218],{},"default",", while keeping endpoint ",[14,221,222],{},"params",[14,224,225],{},"query",[14,227,228],{},"headers",", and ",[14,231,232],{},"body"," typed.",[49,235,237],{"className":51,"code":236,"language":53,"meta":54,"style":54},"\u003Cscript setup lang=\"ts\">\nconst {\n  data: user,\n  pending,\n  error,\n  refresh,\n} = await useEndpoint('\u002Fapi\u002Fusers\u002F:id', {\n  method: 'get',\n  params: { id: '123' },\n  key: 'user:123',\n})\n\nuser.value?.name.toUpperCase()\n\u003C\u002Fscript>\n",[14,238,239,255,262,276,283,290,297,315,323,331,341,346,351,361],{"__ignoreMap":54},[58,240,241,243,245,247,249,251,253],{"class":60,"line":61},[58,242,65],{"class":64},[58,244,69],{"class":68},[58,246,73],{"class":72},[58,248,76],{"class":72},[58,250,79],{"class":64},[58,252,83],{"class":82},[58,254,86],{"class":64},[58,256,257,259],{"class":60,"line":89},[58,258,93],{"class":92},[58,260,261],{"class":64}," {\n",[58,263,264,268,271,274],{"class":60,"line":118},[58,265,267],{"class":266},"sVS1I","  data",[58,269,270],{"class":64},": ",[58,272,273],{"class":72},"user",[58,275,127],{"class":64},[58,277,278,281],{"class":60,"line":130},[58,279,280],{"class":72},"  pending",[58,282,127],{"class":64},[58,284,285,288],{"class":60,"line":142},[58,286,287],{"class":72},"  error",[58,289,127],{"class":64},[58,291,292,295],{"class":60,"line":153},[58,293,294],{"class":72},"  refresh",[58,296,127],{"class":64},[58,298,299,302,304,306,309,311,313],{"class":60,"line":159},[58,300,301],{"class":64},"} ",[58,303,79],{"class":92},[58,305,102],{"class":92},[58,307,308],{"class":105}," useEndpoint",[58,310,109],{"class":64},[58,312,112],{"class":82},[58,314,115],{"class":64},[58,316,317,319,321],{"class":60,"line":166},[58,318,121],{"class":64},[58,320,124],{"class":82},[58,322,127],{"class":64},[58,324,325,327,329],{"class":60,"line":178},[58,326,133],{"class":64},[58,328,136],{"class":82},[58,330,139],{"class":64},[58,332,333,336,339],{"class":60,"line":189},[58,334,335],{"class":64},"  key: ",[58,337,338],{"class":82},"'user:123'",[58,340,127],{"class":64},[58,342,344],{"class":60,"line":343},11,[58,345,156],{"class":64},[58,347,349],{"class":60,"line":348},12,[58,350,163],{"emptyLinePlaceholder":162},[58,352,354,357,359],{"class":60,"line":353},13,[58,355,356],{"class":64},"user.value?.name.",[58,358,184],{"class":105},[58,360,175],{"class":64},[58,362,364,366,368],{"class":60,"line":363},14,[58,365,192],{"class":64},[58,367,69],{"class":68},[58,369,86],{"class":64},[10,371,372,373,378],{},"Use the optional ",[374,375,377],"a",{"href":376},"\u002Fdocs\u002Ftanstack-query","Vue Query"," adapter when the same\nendpoint needs shared server-state caching, retries, invalidation, optimistic\nupdates, prefetching, or infinite-query state.",[10,380,381,382,385],{},"Add ",[14,383,384],{},"operation"," only when you also want a named call target.",[49,387,391],{"className":388,"code":389,"language":390,"meta":54,"style":54},"language-ts shiki shiki-themes github-light-default github-dark-default","export const endpoint = defineEndpoint({\n  operation: 'getUser',\n  params: UserParams,\n  responses: { 200: User },\n})\n\nawait $endpoint('getUser', { params: { id: '123' } })\nawait $endpoint.getUser({ params: { id: '123' } })\n","ts",[14,392,393,412,422,427,438,442,446,465],{"__ignoreMap":54},[58,394,395,398,401,404,406,409],{"class":60,"line":61},[58,396,397],{"class":92},"export",[58,399,400],{"class":92}," const",[58,402,403],{"class":72}," endpoint",[58,405,99],{"class":92},[58,407,408],{"class":105}," defineEndpoint",[58,410,411],{"class":64},"({\n",[58,413,414,417,420],{"class":60,"line":89},[58,415,416],{"class":64},"  operation: ",[58,418,419],{"class":82},"'getUser'",[58,421,127],{"class":64},[58,423,424],{"class":60,"line":118},[58,425,426],{"class":64},"  params: UserParams,\n",[58,428,429,432,435],{"class":60,"line":130},[58,430,431],{"class":64},"  responses: { ",[58,433,434],{"class":72},"200",[58,436,437],{"class":64},": User },\n",[58,439,440],{"class":60,"line":142},[58,441,156],{"class":64},[58,443,444],{"class":60,"line":153},[58,445,163],{"emptyLinePlaceholder":162},[58,447,448,451,453,455,457,460,462],{"class":60,"line":159},[58,449,450],{"class":92},"await",[58,452,106],{"class":105},[58,454,109],{"class":64},[58,456,419],{"class":82},[58,458,459],{"class":64},", { params: { id: ",[58,461,136],{"class":82},[58,463,464],{"class":64}," } })\n",[58,466,467,469,472,475,478,480],{"class":60,"line":166},[58,468,450],{"class":92},[58,470,471],{"class":64}," $endpoint.",[58,473,474],{"class":105},"getUser",[58,476,477],{"class":64},"({ params: { id: ",[58,479,136],{"class":82},[58,481,464],{"class":64},[10,483,484,485,488],{},"The async-data composables also accept operation names. Path calls use ",[14,486,487],{},"method","; operation calls\nalready know their method.",[49,490,492],{"className":388,"code":491,"language":390,"meta":54,"style":54},"await useEndpoint('\u002Fapi\u002Fusers\u002F:id', {\n  method: 'get',\n  params: { id: '123' },\n})\n\nawait useEndpoint('getUser', {\n  params: { id: '123' },\n})\n",[14,493,494,506,514,522,526,530,542,550],{"__ignoreMap":54},[58,495,496,498,500,502,504],{"class":60,"line":61},[58,497,450],{"class":92},[58,499,308],{"class":105},[58,501,109],{"class":64},[58,503,112],{"class":82},[58,505,115],{"class":64},[58,507,508,510,512],{"class":60,"line":89},[58,509,121],{"class":64},[58,511,124],{"class":82},[58,513,127],{"class":64},[58,515,516,518,520],{"class":60,"line":118},[58,517,133],{"class":64},[58,519,136],{"class":82},[58,521,139],{"class":64},[58,523,524],{"class":60,"line":130},[58,525,156],{"class":64},[58,527,528],{"class":60,"line":142},[58,529,163],{"emptyLinePlaceholder":162},[58,531,532,534,536,538,540],{"class":60,"line":153},[58,533,450],{"class":92},[58,535,308],{"class":105},[58,537,109],{"class":64},[58,539,419],{"class":82},[58,541,115],{"class":64},[58,543,544,546,548],{"class":60,"line":159},[58,545,133],{"class":64},[58,547,136],{"class":82},[58,549,139],{"class":64},[58,551,552],{"class":60,"line":166},[58,553,156],{"class":64},[10,555,556,557,561],{},"See ",[374,558,560],{"href":559},"\u002Fdocs\u002Fresponses","Responses"," for status-aware typed results and raw Web Response calls.",[23,563,565],{"id":564},"generated-helper-types","Generated helper types",[10,567,568,569,571],{},"Import helper types from ",[14,570,20],{}," when shared app code needs to reference an operation, request call, or response body without manually duplicating types.",[49,573,575],{"className":388,"code":574,"language":390,"meta":54,"style":54},"import type {\n  $EndpointCall,\n  $EndpointPathCall,\n  $EndpointPathResponse,\n  $EndpointRawResponse,\n  $EndpointResult,\n  $EndpointResponse,\n  $UseEndpointResultPathCall,\n  EndpointMethod,\n  EndpointOperation,\n  EndpointPath,\n} from '#endpoints'\n\ntype Path = EndpointPath\ntype GetUserMethod = EndpointMethod\u003C'\u002Fapi\u002Fusers\u002F:id'>\ntype User = $EndpointPathResponse\u003C'\u002Fapi\u002Fusers\u002F:id', 'get'>\ntype UserCall = $EndpointPathCall\u003C'\u002Fapi\u002Fusers\u002F:id', 'get'>\n\n\u002F\u002F Operation helpers are available when the route declares operation: 'getUser'.\ntype Operation = EndpointOperation\ntype UserOperationResponse = $EndpointResponse\u003C'getUser'>\ntype UserOperationCall = $EndpointCall\u003C'getUser'>\ntype UserOperationResult = $EndpointResult\u003C'getUser'>\ntype UserOperationRawResponse = $EndpointRawResponse\u003C'getUser'>\ntype UserResultState = $UseEndpointResultPathCall\u003C'\u002Fapi\u002Fusers\u002F:id', 'get'>\n",[14,576,577,587,592,597,602,607,612,617,622,627,632,637,647,651,664,683,706,729,734,741,754,773,792,811,830],{"__ignoreMap":54},[58,578,579,582,585],{"class":60,"line":61},[58,580,581],{"class":92},"import",[58,583,584],{"class":92}," type",[58,586,261],{"class":64},[58,588,589],{"class":60,"line":89},[58,590,591],{"class":64},"  $EndpointCall,\n",[58,593,594],{"class":60,"line":118},[58,595,596],{"class":64},"  $EndpointPathCall,\n",[58,598,599],{"class":60,"line":130},[58,600,601],{"class":64},"  $EndpointPathResponse,\n",[58,603,604],{"class":60,"line":142},[58,605,606],{"class":64},"  $EndpointRawResponse,\n",[58,608,609],{"class":60,"line":153},[58,610,611],{"class":64},"  $EndpointResult,\n",[58,613,614],{"class":60,"line":159},[58,615,616],{"class":64},"  $EndpointResponse,\n",[58,618,619],{"class":60,"line":166},[58,620,621],{"class":64},"  $UseEndpointResultPathCall,\n",[58,623,624],{"class":60,"line":178},[58,625,626],{"class":64},"  EndpointMethod,\n",[58,628,629],{"class":60,"line":189},[58,630,631],{"class":64},"  EndpointOperation,\n",[58,633,634],{"class":60,"line":343},[58,635,636],{"class":64},"  EndpointPath,\n",[58,638,639,641,644],{"class":60,"line":348},[58,640,301],{"class":64},[58,642,643],{"class":92},"from",[58,645,646],{"class":82}," '#endpoints'\n",[58,648,649],{"class":60,"line":353},[58,650,163],{"emptyLinePlaceholder":162},[58,652,653,656,659,661],{"class":60,"line":363},[58,654,655],{"class":92},"type",[58,657,658],{"class":266}," Path",[58,660,99],{"class":92},[58,662,663],{"class":266}," EndpointPath\n",[58,665,667,669,672,674,677,679,681],{"class":60,"line":666},15,[58,668,655],{"class":92},[58,670,671],{"class":266}," GetUserMethod",[58,673,99],{"class":92},[58,675,676],{"class":266}," EndpointMethod",[58,678,65],{"class":64},[58,680,112],{"class":82},[58,682,86],{"class":64},[58,684,686,688,691,693,696,698,700,702,704],{"class":60,"line":685},16,[58,687,655],{"class":92},[58,689,690],{"class":266}," User",[58,692,99],{"class":92},[58,694,695],{"class":266}," $EndpointPathResponse",[58,697,65],{"class":64},[58,699,112],{"class":82},[58,701,43],{"class":64},[58,703,124],{"class":82},[58,705,86],{"class":64},[58,707,709,711,714,716,719,721,723,725,727],{"class":60,"line":708},17,[58,710,655],{"class":92},[58,712,713],{"class":266}," UserCall",[58,715,99],{"class":92},[58,717,718],{"class":266}," $EndpointPathCall",[58,720,65],{"class":64},[58,722,112],{"class":82},[58,724,43],{"class":64},[58,726,124],{"class":82},[58,728,86],{"class":64},[58,730,732],{"class":60,"line":731},18,[58,733,163],{"emptyLinePlaceholder":162},[58,735,737],{"class":60,"line":736},19,[58,738,740],{"class":739},"sA0OV","\u002F\u002F Operation helpers are available when the route declares operation: 'getUser'.\n",[58,742,744,746,749,751],{"class":60,"line":743},20,[58,745,655],{"class":92},[58,747,748],{"class":266}," Operation",[58,750,99],{"class":92},[58,752,753],{"class":266}," EndpointOperation\n",[58,755,757,759,762,764,767,769,771],{"class":60,"line":756},21,[58,758,655],{"class":92},[58,760,761],{"class":266}," UserOperationResponse",[58,763,99],{"class":92},[58,765,766],{"class":266}," $EndpointResponse",[58,768,65],{"class":64},[58,770,419],{"class":82},[58,772,86],{"class":64},[58,774,776,778,781,783,786,788,790],{"class":60,"line":775},22,[58,777,655],{"class":92},[58,779,780],{"class":266}," UserOperationCall",[58,782,99],{"class":92},[58,784,785],{"class":266}," $EndpointCall",[58,787,65],{"class":64},[58,789,419],{"class":82},[58,791,86],{"class":64},[58,793,795,797,800,802,805,807,809],{"class":60,"line":794},23,[58,796,655],{"class":92},[58,798,799],{"class":266}," UserOperationResult",[58,801,99],{"class":92},[58,803,804],{"class":266}," $EndpointResult",[58,806,65],{"class":64},[58,808,419],{"class":82},[58,810,86],{"class":64},[58,812,814,816,819,821,824,826,828],{"class":60,"line":813},24,[58,815,655],{"class":92},[58,817,818],{"class":266}," UserOperationRawResponse",[58,820,99],{"class":92},[58,822,823],{"class":266}," $EndpointRawResponse",[58,825,65],{"class":64},[58,827,419],{"class":82},[58,829,86],{"class":64},[58,831,833,835,838,840,843,845,847,849,851],{"class":60,"line":832},25,[58,834,655],{"class":92},[58,836,837],{"class":266}," UserResultState",[58,839,99],{"class":92},[58,841,842],{"class":266}," $UseEndpointResultPathCall",[58,844,65],{"class":64},[58,846,112],{"class":82},[58,848,43],{"class":64},[58,850,124],{"class":82},[58,852,86],{"class":64},[854,855,856],"style",{},"html pre.shiki code .saQ_J, html code.shiki .saQ_J{--shiki-light:#1F2328;--shiki-dark:#E6EDF3}html pre.shiki code .snZHK, html code.shiki .snZHK{--shiki-light:#116329;--shiki-dark:#7EE787}html pre.shiki code .sOOdx, html code.shiki .sOOdx{--shiki-light:#0550AE;--shiki-dark:#79C0FF}html pre.shiki code .sZItA, html code.shiki .sZItA{--shiki-light:#0A3069;--shiki-dark:#A5D6FF}html pre.shiki code .swxxe, html code.shiki .swxxe{--shiki-light:#CF222E;--shiki-dark:#FF7B72}html pre.shiki code .s9HWX, html code.shiki .s9HWX{--shiki-light:#8250DF;--shiki-dark:#D2A8FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sVS1I, html code.shiki .sVS1I{--shiki-light:#953800;--shiki-dark:#FFA657}html pre.shiki code .sA0OV, html code.shiki .sA0OV{--shiki-light:#6E7781;--shiki-dark:#8B949E}",{"title":54,"searchDepth":89,"depth":89,"links":858},[859,860],{"id":25,"depth":89,"text":26},{"id":564,"depth":89,"text":565},"Call server routes by typed path, method, or operation name.","md",{},"\u002Fdocs\u002Fclient",{"title":5,"description":861},"docs\u002Fclient","C4Jgb0xUUQbIoYAlY2iC1B1vJAz9iIRn65oOZu561tE",{"left":869,"top":869,"width":813,"height":813,"rotate":869,"vFlip":870,"hFlip":870,"body":871},0,false,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":869,"top":869,"width":813,"height":813,"rotate":869,"vFlip":870,"hFlip":870,"body":873,"hidden":162},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5c.08-1.25-.27-2.48-1-3.5c.28-1.15.28-2.35 0-3.5c0 0-1 0-3 1.5c-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.4 5.4 0 0 0 4 9c0 3.5 3 5.5 6 5.5c-.39.49-.68 1.05-.85 1.65S8.93 17.38 9 18v4\"\u002F>\u003Cpath d=\"M9 18c-4.51 2-5-2-7-2\"\u002F>\u003C\u002Fg>",{"left":869,"top":869,"width":813,"height":813,"rotate":869,"vFlip":870,"hFlip":870,"body":875},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",1787723882281]