[{"data":1,"prerenderedAt":678},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":677,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Findex.md",{},"Axios",{"type":8,"value":9,"toc":668},"minimark",[10,14,48,53,153,183,187,224,228,316,328,332,640],[11,12,13],"p",{},"Generates one typed async function per OpenAPI operation that sends the request with axios and returns a result keyed by status code.",[11,15,16,17,21,22,21,25,21,28,31,32,35,36,39,40,43,44,47],{},"Each function takes grouped ",[18,19,20],"code",{},"path",", ",[18,23,24],{},"query",[18,26,27],{},"headers",[18,29,30],{},"cookies",", and ",[18,33,34],{},"body"," options. The query plugins and ",[18,37,38],{},"@kubb\u002Fplugin-mcp"," call these functions. The runtime is copied into ",[18,41,42],{},".kubb\u002F",", so the generated code imports only ",[18,45,46],{},"axios",".",[49,50,52],"h2",{"id":51},"installation","Installation",[54,55,57,80,100,118,136],"code-group",{"sync":56},"install",[58,59,64],"pre",{"language":60,"filename":61,"code":62,"class":63},"shell","kubb","kubb add plugin-axios","highlights",[18,65,67],{"class":66},"language-shell",[68,69,72,76],"span",{"class":70,"style":71},"line","display: inline",[68,73,75],{"style":74},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[68,77,79],{"style":78},"color:#24292e;--hls-dark:#e1e4e8","add plugin-axios",[58,81,84],{"language":60,"filename":82,"code":83,"class":63},"bun","bun add -d @kubb\u002Fplugin-axios",[18,85,86],{"class":66},[68,87,88,91,94,97],{"class":70,"style":71},[68,89,90],{"style":74},"bun ",[68,92,93],{"style":78},"add -d ",[68,95,96],{"style":78},"@",[68,98,99],{"style":78},"kubb\u002Fplugin-axios",[58,101,104],{"language":60,"filename":102,"code":103,"class":63},"pnpm","pnpm add -D @kubb\u002Fplugin-axios",[18,105,106],{"class":66},[68,107,108,111,114,116],{"class":70,"style":71},[68,109,110],{"style":74},"pnpm ",[68,112,113],{"style":78},"add -D ",[68,115,96],{"style":78},[68,117,99],{"style":78},[58,119,122],{"language":60,"filename":120,"code":121,"class":63},"npm","npm install --save-dev @kubb\u002Fplugin-axios",[18,123,124],{"class":66},[68,125,126,129,132,134],{"class":70,"style":71},[68,127,128],{"style":74},"npm ",[68,130,131],{"style":78},"install --save-dev ",[68,133,96],{"style":78},[68,135,99],{"style":78},[58,137,140],{"language":60,"filename":138,"code":139,"class":63},"yarn","yarn add -D @kubb\u002Fplugin-axios",[18,141,142],{"class":66},[68,143,144,147,149,151],{"class":70,"style":71},[68,145,146],{"style":74},"yarn ",[68,148,113],{"style":78},[68,150,96],{"style":78},[68,152,99],{"style":78},[11,154,155,158,159,164,165,168,169,172,173,175,176,182],{},[18,156,157],{},"kubb add"," installs the version the ",[160,161,163],"a",{"href":162},"\u002Fregistry","Kubb registry"," pins and adds ",[18,166,167],{},"pluginAxios()"," to ",[18,170,171],{},"kubb.config.ts",". It needs a ",[18,174,171],{},", so run ",[160,177,179],{"href":178},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",[18,180,181],{},"kubb init"," first in a new project.",[49,184,186],{"id":185},"setup","Setup",[188,189,190,205,218],"ul",{},[191,192,193,194,197,198,201,202,47],"li",{},"Add ",[18,195,196],{},"@kubb\u002Fplugin-ts"," for the operation types, or ",[18,199,200],{},"@kubb\u002Fplugin-zod"," with ",[18,203,204],{},"inferred: true",[191,206,193,207,209,210,213,214,217],{},[18,208,200],{}," and install ",[18,211,212],{},"zod"," v4 when you set ",[18,215,216],{},"validator",". Generation fails without the plugin.",[191,219,220,221,223],{},"Install ",[18,222,46],{}," 1.20 or a later 1.x release in the app that runs the generated code.",[49,225,227],{"id":226},"options-worth-knowing","Options worth knowing",[229,230,231,244],"table",{},[232,233,234],"thead",{},[235,236,237,241],"tr",{},[238,239,240],"th",{},"Option",[238,242,243],{},"Set it to",[245,246,247,262,278,291,304],"tbody",{},[235,248,249,255],{},[250,251,252],"td",{},[18,253,254],{},"baseURL",[250,256,257,258,261],{},"The starting host. The spec's top-level ",[18,259,260],{},"servers"," URL is not used.",[235,263,264,268],{},[250,265,266],{},[18,267,216],{},[250,269,270,273,274,277],{},[18,271,272],{},"'zod'"," to check response bodies, or ",[18,275,276],{},"{ request, params, response }"," per part.",[235,279,280,285],{},[250,281,282],{},[18,283,284],{},"throwOnErrorDefault",[250,286,287,290],{},[18,288,289],{},"false"," to return non-2xx responses as values.",[235,292,293,298],{},[250,294,295],{},[18,296,297],{},"returnType",[250,299,300,303],{},[18,301,302],{},"'data'"," to resolve to the success body instead of the full result.",[235,305,306,311],{},[250,307,308],{},[18,309,310],{},"sdk",[250,312,313,314,47],{},"Classes instead of functions. Leave it unset for the query plugins and ",[18,315,38],{},[11,317,318,319,323,324,47],{},"Next, ",[160,320,322],{"href":321},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fcalling-operations","call operations",", or see every option and its default in ",[160,325,327],{"href":326},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions","Options",[49,329,331],{"id":330},"example","Example",[54,333,334,538,602],{},[58,335,338],{"language":336,"filename":171,"code":337,"class":63},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { adapterOas } from '@kubb\u002Fadapter-oas'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginAxios } from '@kubb\u002Fplugin-axios'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  adapter: adapterOas({ integerType: 'number' }),\n  plugins: [pluginTs(), pluginAxios({ baseURL: 'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' })],\n})",[18,339,341,364,365,364,381,364,397,364,413,364,415,364,429,364,446,364,469,364,497,364,534],{"class":340},"language-typescript",[68,342,343,347,351,354,357,360],{"class":70,"style":71},[68,344,346],{"style":345},"color:#d73a49;--hls-dark:#f97583","import ",[68,348,350],{"style":349},"color:#005cc5;--hls-dark:#79b8ff","{ ",[68,352,353],{"style":78},"defineConfig ",[68,355,356],{"style":349},"} ",[68,358,359],{"style":345},"from ",[68,361,363],{"style":362},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[68,366,367,369,371,374,376,378],{"class":70,"style":71},[68,368,346],{"style":345},[68,370,350],{"style":349},[68,372,373],{"style":78},"adapterOas ",[68,375,356],{"style":349},[68,377,359],{"style":345},[68,379,380],{"style":362},"'@kubb\u002Fadapter-oas'",[68,382,383,385,387,390,392,394],{"class":70,"style":71},[68,384,346],{"style":345},[68,386,350],{"style":349},[68,388,389],{"style":78},"pluginTs ",[68,391,356],{"style":349},[68,393,359],{"style":345},[68,395,396],{"style":362},"'@kubb\u002Fplugin-ts'",[68,398,399,401,403,406,408,410],{"class":70,"style":71},[68,400,346],{"style":345},[68,402,350],{"style":349},[68,404,405],{"style":78},"pluginAxios ",[68,407,356],{"style":349},[68,409,359],{"style":345},[68,411,412],{"style":362},"'@kubb\u002Fplugin-axios'",[68,414],{"class":70,"style":71},[68,416,417,420,423,426],{"class":70,"style":71},[68,418,419],{"style":345},"export ",[68,421,422],{"style":345},"default ",[68,424,425],{"style":74},"defineConfig",[68,427,428],{"style":349},"({",[68,430,431,434,437,440,443],{"class":70,"style":71},[68,432,433],{"style":349},"  ",[68,435,436],{"style":349},"input",[68,438,439],{"style":345},": ",[68,441,442],{"style":362},"'.\u002FpetStore.yaml'",[68,444,445],{"style":345},",",[68,447,448,450,453,455,457,459,461,464,467],{"class":70,"style":71},[68,449,433],{"style":345},[68,451,452],{"style":349},"output",[68,454,439],{"style":345},[68,456,350],{"style":349},[68,458,20],{"style":349},[68,460,439],{"style":345},[68,462,463],{"style":362},"'.\u002Fsrc\u002Fgen' ",[68,465,466],{"style":349},"}",[68,468,445],{"style":345},[68,470,471,473,476,478,481,484,487,489,492,495],{"class":70,"style":71},[68,472,433],{"style":345},[68,474,475],{"style":349},"adapter",[68,477,439],{"style":345},[68,479,480],{"style":74},"adapterOas",[68,482,483],{"style":349},"({ ",[68,485,486],{"style":349},"integerType",[68,488,439],{"style":345},[68,490,491],{"style":362},"'number' ",[68,493,494],{"style":349},"})",[68,496,445],{"style":345},[68,498,499,501,504,506,509,512,515,517,520,522,524,526,529,532],{"class":70,"style":71},[68,500,433],{"style":345},[68,502,503],{"style":349},"plugins",[68,505,439],{"style":345},[68,507,508],{"style":349},"[",[68,510,511],{"style":74},"pluginTs",[68,513,514],{"style":349},"()",[68,516,21],{"style":345},[68,518,519],{"style":74},"pluginAxios",[68,521,483],{"style":349},[68,523,254],{"style":349},[68,525,439],{"style":345},[68,527,528],{"style":362},"'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' ",[68,530,531],{"style":349},"})]",[68,533,445],{"style":345},[68,535,536],{"class":70,"style":71},[68,537,494],{"style":349},[58,539,542],{"language":336,"filename":540,"code":541,"class":63},"src\u002Fapp.ts","import { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nconst { data } = await getPetById({ path: { petId: 1 } })",[18,543,544,364,560,364,562],{"class":340},[68,545,546,548,550,553,555,557],{"class":70,"style":71},[68,547,346],{"style":345},[68,549,350],{"style":349},[68,551,552],{"style":78},"getPetById ",[68,554,356],{"style":349},[68,556,359],{"style":345},[68,558,559],{"style":362},"'.\u002Fgen\u002Fclients\u002FgetPetById'",[68,561],{"class":70,"style":71},[68,563,564,567,569,572,574,577,580,583,585,587,589,591,594,596,599],{"class":70,"style":71},[68,565,566],{"style":345},"const ",[68,568,350],{"style":349},[68,570,571],{"style":78},"data ",[68,573,356],{"style":349},[68,575,576],{"style":345},"= ",[68,578,579],{"style":345},"await ",[68,581,582],{"style":74},"getPetById",[68,584,483],{"style":349},[68,586,20],{"style":349},[68,588,439],{"style":345},[68,590,350],{"style":349},[68,592,593],{"style":349},"petId",[68,595,439],{"style":345},[68,597,598],{"style":349},"1 ",[68,600,601],{"style":349},"} })",[58,603,607],{"language":604,"filename":605,"code":606,"class":63},"text","Generated files","src\u002Fgen\u002F\n├── .kubb\u002F          # the runtime: client.ts, core.ts, config.ts, serializers\u002F, ...\n├── clients\u002F\n│   ├── getPetById.ts\n│   └── index.ts\n└── types\u002F",[18,608,610,364,615,364,620,364,625,364,630,364,635],{"class":609},"language-text",[68,611,612],{"class":70,"style":71},[68,613,614],{"style":78},"src\u002Fgen\u002F",[68,616,617],{"class":70,"style":71},[68,618,619],{"style":78},"├── .kubb\u002F          # the runtime: client.ts, core.ts, config.ts, serializers\u002F, ...",[68,621,622],{"class":70,"style":71},[68,623,624],{"style":78},"├── clients\u002F",[68,626,627],{"class":70,"style":71},[68,628,629],{"style":78},"│   ├── getPetById.ts",[68,631,632],{"class":70,"style":71},[68,633,634],{"style":78},"│   └── index.ts",[68,636,637],{"class":70,"style":71},[68,638,639],{"style":78},"└── types\u002F",[11,641,642,643,649,650,653,654,656,657,660,661,664,665,47],{},"With ",[160,644,646],{"href":645},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[18,647,648],{},"integerType: 'number'",", an ",[18,651,652],{},"int64"," id such as ",[18,655,593],{}," is a ",[18,658,659],{},"number",". With the default ",[18,662,663],{},"bigint",", pass ",[18,666,667],{},"1n",{"title":669,"searchDepth":670,"depth":670,"links":671},"",5,[672,674,675,676],{"id":51,"depth":673,"text":52},2,{"id":185,"depth":673,"text":186},{"id":226,"depth":673,"text":227},{"id":330,"depth":673,"text":331},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios",1795091979502]