[{"data":1,"prerenderedAt":488},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":487,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Findex.md",{},"Axios",{"type":8,"value":9,"toc":478},"minimark",[10,30,61,66,152,173,177,218,222,284,292,296,299],[11,12,13,14,18,19,18,22,25,26,29],"p",{},"The Axios plugin turns each operation in your OpenAPI spec into a typed async function that sends the request with axios. Each function takes grouped ",[15,16,17],"code",{},"path",", ",[15,20,21],{},"query",[15,23,24],{},"headers",", and ",[15,27,28],{},"body"," parameters and returns a result keyed by status code.",[11,31,32,33,18,36,25,39,42,43,46,47,18,50,25,53,56,57,60],{},"The query plugins (",[15,34,35],{},"@kubb\u002Fplugin-react-query",[15,37,38],{},"@kubb\u002Fplugin-vue-query",[15,40,41],{},"@kubb\u002Fplugin-swr",") and ",[15,44,45],{},"@kubb\u002Fplugin-mcp"," call these functions. The plugin also copies its runtime files (",[15,48,49],{},"client.ts",[15,51,52],{},"serializers.ts",[15,54,55],{},"standardSchema.ts",") to ",[15,58,59],{},".kubb\u002F"," in the root output folder.",[62,63,65],"h2",{"id":64},"installation","Installation",[67,68,70,99,117,135],"code-group",{"sync":69},"package-manager",[71,72,77],"pre",{"language":73,"filename":74,"code":75,"class":76},"shell","bun","bun add -d @kubb\u002Fplugin-axios","highlights",[15,78,80],{"class":79},"language-shell",[81,82,85,89,93,96],"span",{"class":83,"style":84},"line","display: inline",[81,86,88],{"style":87},"color:#6f42c1;--hls-dark:#b392f0","bun ",[81,90,92],{"style":91},"color:#24292e;--hls-dark:#e1e4e8","add -d ",[81,94,95],{"style":91},"@",[81,97,98],{"style":91},"kubb\u002Fplugin-axios",[71,100,103],{"language":73,"filename":101,"code":102,"class":76},"pnpm","pnpm add -D @kubb\u002Fplugin-axios",[15,104,105],{"class":79},[81,106,107,110,113,115],{"class":83,"style":84},[81,108,109],{"style":87},"pnpm ",[81,111,112],{"style":91},"add -D ",[81,114,95],{"style":91},[81,116,98],{"style":91},[71,118,121],{"language":73,"filename":119,"code":120,"class":76},"npm","npm install --save-dev @kubb\u002Fplugin-axios",[15,122,123],{"class":79},[81,124,125,128,131,133],{"class":83,"style":84},[81,126,127],{"style":87},"npm ",[81,129,130],{"style":91},"install --save-dev ",[81,132,95],{"style":91},[81,134,98],{"style":91},[71,136,139],{"language":73,"filename":137,"code":138,"class":76},"yarn","yarn add -D @kubb\u002Fplugin-axios",[15,140,141],{"class":79},[81,142,143,146,148,150],{"class":83,"style":84},[81,144,145],{"style":87},"yarn ",[81,147,112],{"style":91},[81,149,95],{"style":91},[81,151,98],{"style":91},[11,153,154,155,158,159,164,165,168,169,172],{},"Or run ",[15,156,157],{},"kubb add plugin-axios"," to install the version the ",[160,161,163],"a",{"href":162},"\u002Fregistry","Kubb registry"," pins and add ",[15,166,167],{},"pluginAxios()"," to ",[15,170,171],{},"kubb.config.ts",".",[62,174,176],{"id":175},"setup","Setup",[178,179,180,195,211],"ul",{},[181,182,183,184,187,188,191,192,172],"li",{},"Add ",[15,185,186],{},"@kubb\u002Fplugin-ts"," for the operation types, or ",[15,189,190],{},"@kubb\u002Fplugin-zod"," with ",[15,193,194],{},"inferred: true",[181,196,183,197,199,200,203,204,207,208,210],{},[15,198,190],{}," when you set ",[15,201,202],{},"validator",", and install ",[15,205,206],{},"zod"," v4. Without the plugin, ",[15,209,202],{}," does nothing.",[181,212,213,214,217],{},"Install ",[15,215,216],{},"axios"," 1.20 or a later v1 release in the app that uses the generated code.",[62,219,221],{"id":220},"options-worth-knowing","Options worth knowing",[178,223,224,240,253,262,272],{},[181,225,226,229,230,233,234,236,237,172],{},[15,227,228],{},"baseURL"," is prepended to every request. The spec's ",[15,231,232],{},"servers"," URL is not used, so without ",[15,235,228],{}," you set one at runtime with ",[15,238,239],{},"client.setConfig({ baseURL })",[181,241,242,245,246,248,249,252],{},[15,243,244],{},"validator: 'zod'"," validates response bodies with the schemas from ",[15,247,190],{},". Use ",[15,250,251],{},"{ request: 'zod', response: 'zod' }"," to also validate request bodies.",[181,254,255,258,259,172],{},[15,256,257],{},"throwOnErrorDefault: false"," returns non-2xx responses as values instead of throwing. A single call can still pass ",[15,260,261],{},"throwOnError",[181,263,264,267,268,271],{},[15,265,266],{},"returnType: 'data'"," makes a call resolve to the success body instead of the full result. With ",[15,269,270],{},"throwOnError: false",", the call still returns the full result.",[181,273,274,277,278,280,281,283],{},[15,275,276],{},"sdk"," generates a class-based SDK, grouped by tag or flat, instead of standalone functions. The query plugins and ",[15,279,45],{}," need the standalone functions, so leave ",[15,282,276],{}," unset when you use them.",[11,285,286,287,291],{},"See ",[160,288,290],{"href":289},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions","Options"," for every option and its default.",[62,293,295],{"id":294},"example","Example",[11,297,298],{},"The config below generates an axios client that sends every request to the Petstore API.",[71,300,303],{"language":301,"filename":171,"code":302,"class":76},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\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  plugins: [\n    pluginTs(),\n    pluginAxios({ baseURL: 'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' }),\n  ],\n})",[15,304,306,329,330,329,346,329,362,329,364,329,378,329,395,329,418,329,430,329,443,329,465,329,474],{"class":305},"language-typescript",[81,307,308,312,316,319,322,325],{"class":83,"style":84},[81,309,311],{"style":310},"color:#d73a49;--hls-dark:#f97583","import ",[81,313,315],{"style":314},"color:#005cc5;--hls-dark:#79b8ff","{ ",[81,317,318],{"style":91},"defineConfig ",[81,320,321],{"style":314},"} ",[81,323,324],{"style":310},"from ",[81,326,328],{"style":327},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[81,331,332,334,336,339,341,343],{"class":83,"style":84},[81,333,311],{"style":310},[81,335,315],{"style":314},[81,337,338],{"style":91},"pluginTs ",[81,340,321],{"style":314},[81,342,324],{"style":310},[81,344,345],{"style":327},"'@kubb\u002Fplugin-ts'",[81,347,348,350,352,355,357,359],{"class":83,"style":84},[81,349,311],{"style":310},[81,351,315],{"style":314},[81,353,354],{"style":91},"pluginAxios ",[81,356,321],{"style":314},[81,358,324],{"style":310},[81,360,361],{"style":327},"'@kubb\u002Fplugin-axios'",[81,363],{"class":83,"style":84},[81,365,366,369,372,375],{"class":83,"style":84},[81,367,368],{"style":310},"export ",[81,370,371],{"style":310},"default ",[81,373,374],{"style":87},"defineConfig",[81,376,377],{"style":314},"({",[81,379,380,383,386,389,392],{"class":83,"style":84},[81,381,382],{"style":314},"  ",[81,384,385],{"style":314},"input",[81,387,388],{"style":310},": ",[81,390,391],{"style":327},"'.\u002FpetStore.yaml'",[81,393,394],{"style":310},",",[81,396,397,399,402,404,406,408,410,413,416],{"class":83,"style":84},[81,398,382],{"style":310},[81,400,401],{"style":314},"output",[81,403,388],{"style":310},[81,405,315],{"style":314},[81,407,17],{"style":314},[81,409,388],{"style":310},[81,411,412],{"style":327},"'.\u002Fsrc\u002Fgen' ",[81,414,415],{"style":314},"}",[81,417,394],{"style":310},[81,419,420,422,425,427],{"class":83,"style":84},[81,421,382],{"style":310},[81,423,424],{"style":314},"plugins",[81,426,388],{"style":310},[81,428,429],{"style":314},"[",[81,431,432,435,438,441],{"class":83,"style":84},[81,433,434],{"style":314},"    ",[81,436,437],{"style":87},"pluginTs",[81,439,440],{"style":314},"()",[81,442,394],{"style":310},[81,444,445,447,450,453,455,457,460,463],{"class":83,"style":84},[81,446,434],{"style":310},[81,448,449],{"style":87},"pluginAxios",[81,451,452],{"style":314},"({ ",[81,454,228],{"style":314},[81,456,388],{"style":310},[81,458,459],{"style":327},"'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' ",[81,461,462],{"style":314},"})",[81,464,394],{"style":310},[81,466,467,469,472],{"class":83,"style":84},[81,468,382],{"style":310},[81,470,471],{"style":314},"]",[81,473,394],{"style":310},[81,475,476],{"class":83,"style":84},[81,477,462],{"style":314},{"title":479,"searchDepth":480,"depth":480,"links":481},"",5,[482,484,485,486],{"id":64,"depth":483,"text":65},2,{"id":175,"depth":483,"text":176},{"id":220,"depth":483,"text":221},{"id":294,"depth":483,"text":295},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios",1793647021099]