[{"data":1,"prerenderedAt":1990},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1989,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests.md",{},"Configure requests",{"type":8,"value":9,"toc":1970},"minimark",[10,14,19,31,116,147,378,382,385,458,473,485,489,504,592,598,739,750,761,765,771,850,1197,1242,1254,1383,1390,1395,1413,1505,1512,1519,1523,1526,1553,1569,1572,1582,1697,1700,1713,1722,1761,1764,1774,1934,1937,1940,1950],[11,12,13],"p",{},"Set the base URL, credentials, shared headers, and interceptors on the generated client, for every call or for one.",[15,16,18],"h2",{"id":17},"where-settings-apply","Where settings apply",[11,20,21,22,26,27,30],{},"Every generated function sends through the shared ",[23,24,25],"code",{},"client"," from ",[23,28,29],{},".kubb\u002Fclient.ts",", unless a call passes its own:",[32,33,34,50],"table",{},[35,36,37],"thead",{},[38,39,40,44,47],"tr",{},[41,42,43],"th",{},"Scope",[41,45,46],{},"How",[41,48,49],{},"Effect",[51,52,53,79,92,105],"tbody",{},[38,54,55,59,64],{},[56,57,58],"td",{},"Every call",[56,60,61],{},[23,62,63],{},"client.setConfig({ ... })",[56,65,66,67,70,71,74,75,78],{},"Merges into the shared config. ",[23,68,69],{},"headers",", ",[23,72,73],{},"mediaTypes",", and ",[23,76,77],{},"serializer"," merge per key.",[38,80,81,84,89],{},[56,82,83],{},"A separate client",[56,85,86],{},[23,87,88],{},"createClient({ ... })",[56,90,91],{},"Copies the shared config at creation, without its interceptors.",[38,93,94,97,102],{},[56,95,96],{},"A child client",[56,98,99],{},[23,100,101],{},"client.extend({ ... })",[56,103,104],{},"Copies the shared config and runs the parent's interceptors first.",[38,106,107,110,113],{},[56,108,109],{},"One call",[56,111,112],{},"The same key on the call",[56,114,115],{},"Wins over the client for that call.",[11,117,118,119,70,122,70,124,70,127,70,130,70,133,70,136,70,138,70,140,74,143,146],{},"The client takes ",[23,120,121],{},"baseURL",[23,123,69],{},[23,125,126],{},"auth",[23,128,129],{},"credentials",[23,131,132],{},"options",[23,134,135],{},"transport",[23,137,77],{},[23,139,73],{},[23,141,142],{},"validate",[23,144,145],{},"onValidationError",":",[148,149,153],"pre",{"language":150,"code":151,"class":152},"typescript","import { client, createClient } from '.\u002Fgen\u002F.kubb\u002Fclient'\nimport { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nclient.setConfig({ baseURL: import.meta.env.VITE_API_URL, headers: { 'X-Client': 'web' } })\n\nconst tenant = createClient({ baseURL: 'https:\u002F\u002Ftenant.example.com', auth: () => tenantToken })\nawait getPetById({ path: { petId: 1 }, client: tenant })\n\nawait getPetById({ path: { petId: 1 }, baseURL: 'http:\u002F\u002Flocalhost:3000' })","highlights",[23,154,156,187,188,187,204,187,206,187,262,187,264,187,305,187,343,187,345],{"class":155},"language-typescript",[157,158,161,165,169,172,174,177,180,183],"span",{"class":159,"style":160},"line","display: inline",[157,162,164],{"style":163},"color:#d73a49;--hls-dark:#f97583","import ",[157,166,168],{"style":167},"color:#005cc5;--hls-dark:#79b8ff","{ ",[157,170,25],{"style":171},"color:#24292e;--hls-dark:#e1e4e8",[157,173,70],{"style":163},[157,175,176],{"style":171},"createClient ",[157,178,179],{"style":167},"} ",[157,181,182],{"style":163},"from ",[157,184,186],{"style":185},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002F.kubb\u002Fclient'","\n",[157,189,190,192,194,197,199,201],{"class":159,"style":160},[157,191,164],{"style":163},[157,193,168],{"style":167},[157,195,196],{"style":171},"getPetById ",[157,198,179],{"style":167},[157,200,182],{"style":163},[157,202,203],{"style":185},"'.\u002Fgen\u002Fclients\u002FgetPetById'",[157,205],{"class":159,"style":160},[157,207,208,210,213,217,220,222,225,228,230,233,235,238,240,243,245,247,249,251,254,256,259],{"class":159,"style":160},[157,209,25],{"style":171},[157,211,212],{"style":163},".",[157,214,216],{"style":215},"color:#6f42c1;--hls-dark:#b392f0","setConfig",[157,218,219],{"style":167},"({ ",[157,221,121],{"style":167},[157,223,224],{"style":163},": ",[157,226,227],{"style":163},"import",[157,229,212],{"style":163},[157,231,232],{"style":167},"meta",[157,234,212],{"style":163},[157,236,237],{"style":167},"env",[157,239,212],{"style":163},[157,241,242],{"style":167},"VITE_API_URL",[157,244,70],{"style":163},[157,246,69],{"style":167},[157,248,224],{"style":163},[157,250,168],{"style":167},[157,252,253],{"style":185},"'X-Client'",[157,255,224],{"style":163},[157,257,258],{"style":185},"'web' ",[157,260,261],{"style":167},"} })",[157,263],{"class":159,"style":160},[157,265,266,269,272,275,278,280,282,284,287,289,291,293,296,299,302],{"class":159,"style":160},[157,267,268],{"style":163},"const ",[157,270,271],{"style":171},"tenant ",[157,273,274],{"style":163},"= ",[157,276,277],{"style":215},"createClient",[157,279,219],{"style":167},[157,281,121],{"style":167},[157,283,224],{"style":163},[157,285,286],{"style":185},"'https:\u002F\u002Ftenant.example.com'",[157,288,70],{"style":163},[157,290,126],{"style":167},[157,292,224],{"style":163},[157,294,295],{"style":167},"() ",[157,297,298],{"style":163},"=> ",[157,300,301],{"style":171},"tenantToken ",[157,303,304],{"style":167},"})",[157,306,307,310,313,315,318,320,322,325,327,330,333,335,337,339,341],{"class":159,"style":160},[157,308,309],{"style":163},"await ",[157,311,312],{"style":215},"getPetById",[157,314,219],{"style":167},[157,316,317],{"style":167},"path",[157,319,224],{"style":163},[157,321,168],{"style":167},[157,323,324],{"style":167},"petId",[157,326,224],{"style":163},[157,328,329],{"style":167},"1 ",[157,331,332],{"style":167},"}",[157,334,70],{"style":163},[157,336,25],{"style":167},[157,338,224],{"style":163},[157,340,271],{"style":171},[157,342,304],{"style":167},[157,344],{"class":159,"style":160},[157,346,347,349,351,353,355,357,359,361,363,365,367,369,371,373,376],{"class":159,"style":160},[157,348,309],{"style":163},[157,350,312],{"style":215},[157,352,219],{"style":167},[157,354,317],{"style":167},[157,356,224],{"style":163},[157,358,168],{"style":167},[157,360,324],{"style":167},[157,362,224],{"style":163},[157,364,329],{"style":167},[157,366,332],{"style":167},[157,368,70],{"style":163},[157,370,121],{"style":167},[157,372,224],{"style":163},[157,374,375],{"style":185},"'http:\u002F\u002Flocalhost:3000' ",[157,377,304],{"style":167},[15,379,381],{"id":380},"set-the-base-url","Set the base URL",[11,383,384],{},"A call uses the first base URL it finds:",[32,386,387,397],{},[35,388,389],{},[38,390,391,394],{},[41,392,393],{},"Order",[41,395,396],{},"Source",[51,398,399,409,423,433,443],{},[38,400,401,404],{},[56,402,403],{},"1",[56,405,406,408],{},[23,407,121],{}," on the call.",[38,410,411,414],{},[56,412,413],{},"2",[56,415,416,417,420,421,212],{},"The operation's own ",[23,418,419],{},"servers",", then its path's ",[23,422,419],{},[38,424,425,428],{},[56,426,427],{},"3",[56,429,430,431,212],{},"The client passed as ",[23,432,25],{},[38,434,435,438],{},[56,436,437],{},"4",[56,439,440,212],{},[23,441,442],{},"client.setConfig({ baseURL })",[38,444,445,448],{},[56,446,447],{},"5",[56,449,450,451,457],{},"The plugin's ",[452,453,455],"a",{"href":454},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Foptions#baseurl",[23,456,121],{}," option.",[459,460,462,463,465,466,469,470,212],"blockquote",{"as":461},"note","The spec's top-level ",[23,464,419],{}," URL is never used, even with the ",[23,467,468],{},"server"," option of ",[23,471,472],{},"adapterOas",[11,474,475,476,480,481,212],{},"See ",[452,477,479],{"href":478},"#which-server-a-call-picks","Which server a call picks"," and ",[452,482,484],{"href":483},"#named-servers","Named servers",[15,486,488],{"id":487},"authenticate-requests","Authenticate requests",[11,490,491,492,494,495,499,500,503],{},"Set ",[23,493,126],{}," to a token, or to a sync or async function that gets each ",[452,496,498],{"href":497},"https:\u002F\u002Fspec.openapis.org\u002Foas\u002Fv3.1.0#security-scheme-object","security scheme"," of the call. It returns the token, or ",[23,501,502],{},"undefined"," to skip the scheme:",[148,505,507],{"language":150,"code":506,"class":152},"client.setConfig({\n  auth: (auth) => (auth.type === 'apiKey' ? apiKey : localStorage.getItem('token') ?? undefined),\n})",[23,508,509,187,520,187,588],{"class":155},[157,510,511,513,515,517],{"class":159,"style":160},[157,512,25],{"style":171},[157,514,212],{"style":163},[157,516,216],{"style":215},[157,518,519],{"style":167},"({",[157,521,522,525,527,529,532,534,537,539,541,543,545,548,551,554,557,560,562,565,567,570,572,575,577,580,582,585],{"class":159,"style":160},[157,523,524],{"style":167},"  ",[157,526,126],{"style":167},[157,528,224],{"style":163},[157,530,531],{"style":167},"(",[157,533,126],{"style":171},[157,535,536],{"style":167},") ",[157,538,298],{"style":163},[157,540,531],{"style":167},[157,542,126],{"style":171},[157,544,212],{"style":163},[157,546,547],{"style":167},"type ",[157,549,550],{"style":163},"=== ",[157,552,553],{"style":185},"'apiKey' ",[157,555,556],{"style":163},"? ",[157,558,559],{"style":171},"apiKey ",[157,561,224],{"style":163},[157,563,564],{"style":171},"localStorage",[157,566,212],{"style":163},[157,568,569],{"style":215},"getItem",[157,571,531],{"style":167},[157,573,574],{"style":185},"'token'",[157,576,536],{"style":167},[157,578,579],{"style":163},"?? ",[157,581,502],{"style":167},[157,583,584],{"style":167},")",[157,586,587],{"style":163},",",[157,589,590],{"class":159,"style":160},[157,591,304],{"style":167},[11,593,594,595,597],{},"By default, ",[23,596,126],{}," adds no credentials. The scheme decides where the token goes:",[32,599,600,615],{},[35,601,602],{},[38,603,604,607,612],{},[41,605,606],{},"Scheme in the spec",[41,608,609,611],{},[23,610,126],{}," gets",[41,613,614],{},"The token goes to",[51,616,617,635,652,671,688,707,723],{},[38,618,619,625,630],{},[56,620,621,624],{},[23,622,623],{},"http"," bearer",[56,626,627],{},[23,628,629],{},"{ type: 'http', scheme: 'bearer' }",[56,631,632],{},[23,633,634],{},"Authorization: Bearer \u003Ctoken>",[38,636,637,642,647],{},[56,638,639,641],{},[23,640,623],{}," basic",[56,643,644],{},[23,645,646],{},"{ type: 'http', scheme: 'basic' }",[56,648,649],{},[23,650,651],{},"Authorization: Basic \u003Cbase64>",[38,653,654,660,665],{},[56,655,656,659],{},[23,657,658],{},"apiKey"," in header",[56,661,662],{},[23,663,664],{},"{ type: 'apiKey', name, in: 'header' }",[56,666,667,668],{},"the header named ",[23,669,670],{},"name",[38,672,673,678,683],{},[56,674,675,677],{},[23,676,658],{}," in query",[56,679,680],{},[23,681,682],{},"{ type: 'apiKey', name, in: 'query' }",[56,684,685,686],{},"the query parameter ",[23,687,670],{},[38,689,690,695,700],{},[56,691,692,694],{},[23,693,658],{}," in cookie",[56,696,697],{},[23,698,699],{},"{ type: 'apiKey', name, in: 'cookie' }",[56,701,702,703,706],{},"the ",[23,704,705],{},"Cookie"," header",[38,708,709,714,719],{},[56,710,711],{},[23,712,713],{},"oauth2",[56,715,716],{},[23,717,718],{},"{ type: 'oauth2', scopes, flows }",[56,720,721],{},[23,722,634],{},[38,724,725,730,735],{},[56,726,727],{},[23,728,729],{},"openIdConnect",[56,731,732],{},[23,733,734],{},"{ type: 'openIdConnect', scopes, url }",[56,736,737],{},[23,738,634],{},[459,740,741,742,745,746,749],{"as":461},"For basic auth, return the raw ",[23,743,744],{},"username:password",". The runtime base64-encodes it and adds the ",[23,747,748],{},"Basic"," prefix.",[11,751,752,753,480,757,212],{},"For a credential that no security scheme describes, such as a request signature, add a request interceptor. See ",[452,754,756],{"href":755},"#several-security-schemes","Several security schemes",[452,758,760],{"href":759},"#mutual-tls","Mutual TLS",[15,762,764],{"id":763},"add-interceptors","Add interceptors",[11,766,767,770],{},[23,768,769],{},"client.interceptors"," has three stacks. Each handler gets the value the one before it returned:",[32,772,773,789],{},[35,774,775],{},[38,776,777,780,783,786],{},[41,778,779],{},"Stack",[41,781,782],{},"Runs",[41,784,785],{},"Gets",[41,787,788],{},"Returns",[51,790,791,809,827],{},[38,792,793,798,801,806],{},[56,794,795],{},[23,796,797],{},"request",[56,799,800],{},"After the URL, body, and auth are built, before the send.",[56,802,803],{},[23,804,805],{},"ResolvedRequest",[56,807,808],{},"The request.",[38,810,811,816,819,824],{},[56,812,813],{},[23,814,815],{},"response",[56,817,818],{},"After the body is decoded, before the status check and validator.",[56,820,821],{},[23,822,823],{},"DecodedResponse",[56,825,826],{},"The result.",[38,828,829,834,844,847],{},[56,830,831],{},[23,832,833],{},"error",[56,835,836,837,840,841,212],{},"On any failure: ",[23,838,839],{},"ResponseError",", network error, abort, ",[23,842,843],{},"ParseError",[56,845,846],{},"The error",[56,848,849],{},"Another error to throw, or nothing to keep it.",[851,852,853,933,1024],"code-group",{},[148,854,856],{"language":150,"filename":797,"code":855,"class":152},"client.interceptors.request.use((request) => {\n  request.headers['X-Request-ID'] = crypto.randomUUID()\n  return request\n})",[23,857,858,187,888,187,920,187,929],{"class":155},[157,859,860,862,864,867,869,871,873,876,879,881,883,885],{"class":159,"style":160},[157,861,25],{"style":171},[157,863,212],{"style":163},[157,865,866],{"style":167},"interceptors",[157,868,212],{"style":163},[157,870,797],{"style":167},[157,872,212],{"style":163},[157,874,875],{"style":215},"use",[157,877,878],{"style":167},"((",[157,880,797],{"style":171},[157,882,536],{"style":167},[157,884,298],{"style":163},[157,886,887],{"style":167},"{",[157,889,890,892,894,896,898,901,904,907,909,912,914,917],{"class":159,"style":160},[157,891,524],{"style":167},[157,893,797],{"style":171},[157,895,212],{"style":163},[157,897,69],{"style":167},[157,899,900],{"style":167},"[",[157,902,903],{"style":185},"'X-Request-ID'",[157,905,906],{"style":167},"] ",[157,908,274],{"style":163},[157,910,911],{"style":171},"crypto",[157,913,212],{"style":163},[157,915,916],{"style":215},"randomUUID",[157,918,919],{"style":167},"()",[157,921,922,924,927],{"class":159,"style":160},[157,923,524],{"style":167},[157,925,926],{"style":163},"return ",[157,928,797],{"style":171},[157,930,931],{"class":159,"style":160},[157,932,304],{"style":167},[148,934,936],{"language":150,"filename":815,"code":935,"class":152},"client.interceptors.response.use((result) => {\n  console.info(`${result.status} ${result.contentType}`)\n  return result\n})",[23,937,938,187,965,187,1012,187,1020],{"class":155},[157,939,940,942,944,946,948,950,952,954,956,959,961,963],{"class":159,"style":160},[157,941,25],{"style":171},[157,943,212],{"style":163},[157,945,866],{"style":167},[157,947,212],{"style":163},[157,949,815],{"style":167},[157,951,212],{"style":163},[157,953,875],{"style":215},[157,955,878],{"style":167},[157,957,958],{"style":171},"result",[157,960,536],{"style":167},[157,962,298],{"style":163},[157,964,887],{"style":167},[157,966,967,969,972,974,977,979,982,985,987,989,992,994,997,999,1001,1003,1006,1008,1010],{"class":159,"style":160},[157,968,524],{"style":167},[157,970,971],{"style":171},"console",[157,973,212],{"style":163},[157,975,976],{"style":215},"info",[157,978,531],{"style":167},[157,980,981],{"style":185},"`",[157,983,984],{"style":171},"${",[157,986,958],{"style":171},[157,988,212],{"style":163},[157,990,991],{"style":167},"status",[157,993,332],{"style":171},[157,995,996],{"style":185}," ",[157,998,984],{"style":171},[157,1000,958],{"style":171},[157,1002,212],{"style":163},[157,1004,1005],{"style":167},"contentType",[157,1007,332],{"style":171},[157,1009,981],{"style":185},[157,1011,584],{"style":167},[157,1013,1014,1016,1018],{"class":159,"style":160},[157,1015,524],{"style":167},[157,1017,926],{"style":163},[157,1019,958],{"style":171},[157,1021,1022],{"class":159,"style":160},[157,1023,304],{"style":167},[148,1025,1027],{"language":150,"filename":833,"code":1026,"class":152},"import { client, ResponseError } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclass NotFoundError extends Error {}\n\nclient.interceptors.error.use((error) => {\n  if (ResponseError.is(error) && error.status === 401) scheduleTokenRefresh()\n  if (ResponseError.is(error) && error.status === 404) return new NotFoundError(error.message)\n})",[23,1028,1029,187,1048,187,1050,187,1067,187,1069,187,1095,187,1139,187,1193],{"class":155},[157,1030,1031,1033,1035,1037,1039,1042,1044,1046],{"class":159,"style":160},[157,1032,164],{"style":163},[157,1034,168],{"style":167},[157,1036,25],{"style":171},[157,1038,70],{"style":163},[157,1040,1041],{"style":215},"ResponseError ",[157,1043,179],{"style":167},[157,1045,182],{"style":163},[157,1047,186],{"style":185},[157,1049],{"class":159,"style":160},[157,1051,1052,1055,1058,1061,1064],{"class":159,"style":160},[157,1053,1054],{"style":163},"class ",[157,1056,1057],{"style":215},"NotFoundError ",[157,1059,1060],{"style":163},"extends ",[157,1062,1063],{"style":215},"Error ",[157,1065,1066],{"style":167},"{}",[157,1068],{"class":159,"style":160},[157,1070,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091,1093],{"class":159,"style":160},[157,1072,25],{"style":171},[157,1074,212],{"style":163},[157,1076,866],{"style":167},[157,1078,212],{"style":163},[157,1080,833],{"style":167},[157,1082,212],{"style":163},[157,1084,875],{"style":215},[157,1086,878],{"style":167},[157,1088,833],{"style":171},[157,1090,536],{"style":167},[157,1092,298],{"style":163},[157,1094,887],{"style":167},[157,1096,1097,1099,1102,1104,1106,1108,1111,1113,1115,1117,1120,1122,1124,1127,1129,1132,1134,1137],{"class":159,"style":160},[157,1098,524],{"style":167},[157,1100,1101],{"style":163},"if ",[157,1103,531],{"style":167},[157,1105,839],{"style":215},[157,1107,212],{"style":163},[157,1109,1110],{"style":215},"is",[157,1112,531],{"style":167},[157,1114,833],{"style":171},[157,1116,536],{"style":167},[157,1118,1119],{"style":163},"&& ",[157,1121,833],{"style":171},[157,1123,212],{"style":163},[157,1125,1126],{"style":167},"status ",[157,1128,550],{"style":163},[157,1130,1131],{"style":167},"401",[157,1133,536],{"style":167},[157,1135,1136],{"style":215},"scheduleTokenRefresh",[157,1138,919],{"style":167},[157,1140,1141,1143,1145,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165,1167,1169,1172,1174,1176,1179,1182,1184,1186,1188,1191],{"class":159,"style":160},[157,1142,524],{"style":167},[157,1144,1101],{"style":163},[157,1146,531],{"style":167},[157,1148,839],{"style":215},[157,1150,212],{"style":163},[157,1152,1110],{"style":215},[157,1154,531],{"style":167},[157,1156,833],{"style":171},[157,1158,536],{"style":167},[157,1160,1119],{"style":163},[157,1162,833],{"style":171},[157,1164,212],{"style":163},[157,1166,1126],{"style":167},[157,1168,550],{"style":163},[157,1170,1171],{"style":167},"404",[157,1173,536],{"style":167},[157,1175,926],{"style":163},[157,1177,1178],{"style":163},"new ",[157,1180,1181],{"style":215},"NotFoundError",[157,1183,531],{"style":167},[157,1185,833],{"style":171},[157,1187,212],{"style":163},[157,1189,1190],{"style":167},"message",[157,1192,584],{"style":167},[157,1194,1195],{"class":159,"style":160},[157,1196,304],{"style":167},[11,1198,1199,1201,1202,70,1205,70,1208,70,1210,70,1213,70,1216,70,1218,74,1220,1223,1224,1201,1226,70,1229,70,1231,70,1234,70,1236,70,1238,74,1240,212],{},[23,1200,805],{}," has ",[23,1203,1204],{},"url",[23,1206,1207],{},"method",[23,1209,69],{},[23,1211,1212],{},"body",[23,1214,1215],{},"signal",[23,1217,129],{},[23,1219,132],{},[23,1221,1222],{},"stream",". ",[23,1225,823],{},[23,1227,1228],{},"data",[23,1230,991],{},[23,1232,1233],{},"statusText",[23,1235,69],{},[23,1237,1005],{},[23,1239,797],{},[23,1241,815],{},[11,1243,1244,1245,1247,1248,480,1251,146],{},"Handlers run in the order you register them. ",[23,1246,875],{}," returns an id for ",[23,1249,1250],{},"eject",[23,1252,1253],{},"update",[148,1255,1257],{"language":150,"code":1256,"class":152},"const id = client.interceptors.request.use((request) => request)\nclient.interceptors.request.update(id, (request) => ({ ...request, headers: { ...request.headers, 'X-Trace': 'on' } }))\nclient.interceptors.request.eject(id)",[23,1258,1259,187,1294,187,1361],{"class":155},[157,1260,1261,1263,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292],{"class":159,"style":160},[157,1262,268],{"style":163},[157,1264,1265],{"style":171},"id ",[157,1267,274],{"style":163},[157,1269,25],{"style":171},[157,1271,212],{"style":163},[157,1273,866],{"style":167},[157,1275,212],{"style":163},[157,1277,797],{"style":167},[157,1279,212],{"style":163},[157,1281,875],{"style":215},[157,1283,878],{"style":167},[157,1285,797],{"style":171},[157,1287,536],{"style":167},[157,1289,298],{"style":163},[157,1291,797],{"style":171},[157,1293,584],{"style":167},[157,1295,1296,1298,1300,1302,1304,1306,1308,1310,1312,1315,1317,1319,1321,1323,1325,1327,1330,1332,1334,1336,1338,1340,1342,1344,1346,1348,1350,1353,1355,1358],{"class":159,"style":160},[157,1297,25],{"style":171},[157,1299,212],{"style":163},[157,1301,866],{"style":167},[157,1303,212],{"style":163},[157,1305,797],{"style":167},[157,1307,212],{"style":163},[157,1309,1253],{"style":215},[157,1311,531],{"style":167},[157,1313,1314],{"style":171},"id",[157,1316,70],{"style":163},[157,1318,531],{"style":167},[157,1320,797],{"style":171},[157,1322,536],{"style":167},[157,1324,298],{"style":163},[157,1326,219],{"style":167},[157,1328,1329],{"style":163},"...",[157,1331,797],{"style":171},[157,1333,70],{"style":163},[157,1335,69],{"style":167},[157,1337,224],{"style":163},[157,1339,168],{"style":167},[157,1341,1329],{"style":163},[157,1343,797],{"style":171},[157,1345,212],{"style":163},[157,1347,69],{"style":167},[157,1349,70],{"style":163},[157,1351,1352],{"style":185},"'X-Trace'",[157,1354,224],{"style":163},[157,1356,1357],{"style":185},"'on' ",[157,1359,1360],{"style":167},"} }))",[157,1362,1363,1365,1367,1369,1371,1373,1375,1377,1379,1381],{"class":159,"style":160},[157,1364,25],{"style":171},[157,1366,212],{"style":163},[157,1368,866],{"style":167},[157,1370,212],{"style":163},[157,1372,797],{"style":167},[157,1374,212],{"style":163},[157,1376,1250],{"style":215},[157,1378,531],{"style":167},[157,1380,1314],{"style":171},[157,1382,584],{"style":167},[459,1384,1385,1386,1389],{"as":461},"With ",[23,1387,1388],{},"throwOnError: false",", a non-2xx response resolves, so no error handler runs for it.",[1391,1392,1394],"h3",{"id":1393},"native-axios-interceptors","Native axios interceptors",[11,1396,1397,1398,70,1401,1404,1405,1408,1409,1412],{},"For the native ",[23,1399,1400],{},"InternalAxiosRequestConfig",[23,1402,1403],{},"AxiosResponse",", or ",[23,1406,1407],{},"AxiosError",", register on the axios instance that ",[23,1410,1411],{},"getAxiosInstance()"," returns. Native response interceptors see the raw bytes, before Kubb decodes them:",[148,1414,1416],{"language":150,"code":1415,"class":152},"import { getAxiosInstance } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\ngetAxiosInstance().interceptors.request.use((config) => {\n  config.headers.set('traceparent', currentTraceparent())\n  return config\n})",[23,1417,1418,187,1433,187,1435,187,1465,187,1493,187,1501],{"class":155},[157,1419,1420,1422,1424,1427,1429,1431],{"class":159,"style":160},[157,1421,164],{"style":163},[157,1423,168],{"style":167},[157,1425,1426],{"style":171},"getAxiosInstance ",[157,1428,179],{"style":167},[157,1430,182],{"style":163},[157,1432,186],{"style":185},[157,1434],{"class":159,"style":160},[157,1436,1437,1440,1442,1444,1446,1448,1450,1452,1454,1456,1459,1461,1463],{"class":159,"style":160},[157,1438,1439],{"style":215},"getAxiosInstance",[157,1441,919],{"style":167},[157,1443,212],{"style":163},[157,1445,866],{"style":167},[157,1447,212],{"style":163},[157,1449,797],{"style":167},[157,1451,212],{"style":163},[157,1453,875],{"style":215},[157,1455,878],{"style":167},[157,1457,1458],{"style":171},"config",[157,1460,536],{"style":167},[157,1462,298],{"style":163},[157,1464,887],{"style":167},[157,1466,1467,1469,1471,1473,1475,1477,1480,1482,1485,1487,1490],{"class":159,"style":160},[157,1468,524],{"style":167},[157,1470,1458],{"style":171},[157,1472,212],{"style":163},[157,1474,69],{"style":167},[157,1476,212],{"style":163},[157,1478,1479],{"style":215},"set",[157,1481,531],{"style":167},[157,1483,1484],{"style":185},"'traceparent'",[157,1486,70],{"style":163},[157,1488,1489],{"style":215},"currentTraceparent",[157,1491,1492],{"style":167},"())",[157,1494,1495,1497,1499],{"class":159,"style":160},[157,1496,524],{"style":167},[157,1498,926],{"style":163},[157,1500,1458],{"style":171},[157,1502,1503],{"class":159,"style":160},[157,1504,304],{"style":167},[11,1506,1507,1508,212],{},"For the order native and core handlers run in, see ",[452,1509,1511],{"href":1510},"#interceptor-order","Interceptor order",[11,1513,1514,1515,212],{},"Next, ",[452,1516,1518],{"href":1517},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Ftransport","use a custom transport",[15,1520,1522],{"id":1521},"less-common-cases","Less common cases",[1391,1524,479],{"id":1525},"which-server-a-call-picks",[11,1527,1528,1529,1531,1532,1538,1539,1541,1542,1545,1546,1549,1550,212],{},"When an operation or path has its own ",[23,1530,419],{},", the ",[452,1533,1535],{"href":1534},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#server",[23,1536,1537],{},"server.index"," of ",[23,1540,472],{}," picks the entry, falling back to the first. A relative URL such as ",[23,1543,1544],{},"\u002Fv2",", or one with ",[23,1547,1548],{},"{variable}"," placeholders, is skipped, so the call uses the next source in ",[452,1551,381],{"href":1552},"#set-the-base-url",[11,1554,450,1555,1559,1560,1563,1564,1566,1567,212],{},[452,1556,1557],{"href":454},[23,1558,121],{}," option is written into ",[23,1561,1562],{},".kubb\u002Fconfig.ts",", which ",[23,1565,29],{}," passes to ",[23,1568,216],{},[1391,1570,484],{"id":1571},"named-servers",[11,1573,1574,1575,70,1577,1579,1580,146],{},"When an OpenAPI 3.2 server has a ",[23,1576,670],{},[23,1578,29],{}," exports its URL in ",[23,1581,419],{},[851,1583,1584,1647],{},[148,1585,1589],{"language":1586,"filename":1587,"code":1588,"class":152},"yaml","petStore.yaml","servers:\n  - url: https:\u002F\u002Fapi.example.com\n    name: production\n  - url: https:\u002F\u002Fstaging.example.com\n    name: staging",[23,1590,1592,187,1598,187,1610,187,1622,187,1636],{"class":1591},"language-yaml",[157,1593,1594,1596],{"class":159,"style":160},[157,1595,419],{"style":167},[157,1597,146],{"style":163},[157,1599,1600,1603,1605,1607],{"class":159,"style":160},[157,1601,1602],{"style":163},"  - ",[157,1604,1204],{"style":167},[157,1606,224],{"style":163},[157,1608,1609],{"style":185},"https:\u002F\u002Fapi.example.com",[157,1611,1612,1615,1617,1619],{"class":159,"style":160},[157,1613,1614],{"style":185},"    ",[157,1616,670],{"style":167},[157,1618,224],{"style":163},[157,1620,1621],{"style":185},"production",[157,1623,1624,1626,1629,1631,1633],{"class":159,"style":160},[157,1625,524],{"style":185},[157,1627,1628],{"style":163},"- ",[157,1630,1204],{"style":167},[157,1632,224],{"style":163},[157,1634,1635],{"style":185},"https:\u002F\u002Fstaging.example.com",[157,1637,1638,1640,1642,1644],{"class":159,"style":160},[157,1639,1614],{"style":185},[157,1641,670],{"style":167},[157,1643,224],{"style":163},[157,1645,1646],{"style":185},"staging",[148,1648,1651],{"language":150,"filename":1649,"code":1650,"class":152},"src\u002Fapi.ts","import { client, servers } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nclient.setConfig({ baseURL: servers.staging })",[23,1652,1653,187,1672,187,1674],{"class":155},[157,1654,1655,1657,1659,1661,1663,1666,1668,1670],{"class":159,"style":160},[157,1656,164],{"style":163},[157,1658,168],{"style":167},[157,1660,25],{"style":171},[157,1662,70],{"style":163},[157,1664,1665],{"style":171},"servers ",[157,1667,179],{"style":167},[157,1669,182],{"style":163},[157,1671,186],{"style":185},[157,1673],{"class":159,"style":160},[157,1675,1676,1678,1680,1682,1684,1686,1688,1690,1692,1695],{"class":159,"style":160},[157,1677,25],{"style":171},[157,1679,212],{"style":163},[157,1681,216],{"style":215},[157,1683,219],{"style":167},[157,1685,121],{"style":167},[157,1687,224],{"style":163},[157,1689,419],{"style":171},[157,1691,212],{"style":163},[157,1693,1694],{"style":167},"staging ",[157,1696,304],{"style":167},[1391,1698,756],{"id":1699},"several-security-schemes",[11,1701,1702,1703,1705,1706,1709,1710,1712],{},"When an operation lists several security requirements, the runtime sends the first one whose schemes all get a token. A requirement that needs an API key and a session cookie sends both. A header or query key you set yourself wins over the token. An ",[23,1704,713],{}," scheme also passes ",[23,1707,1708],{},"metadataUrl"," to ",[23,1711,126],{}," when the spec has one.",[11,1714,1715,1717,1718,1721],{},[23,1716,29],{}," exports the spec's schemes by name as ",[23,1719,1720],{},"securitySchemes",", and each generated call points at its own, with the scopes it needs:",[148,1723,1725],{"language":150,"code":1724,"class":152},"security: [{ ...securitySchemes.petstore_auth, scopes: ['write:pets'] }]",[23,1726,1727],{"class":155},[157,1728,1729,1732,1734,1737,1739,1741,1743,1746,1748,1751,1753,1755,1758],{"class":159,"style":160},[157,1730,1731],{"style":171},"security",[157,1733,224],{"style":163},[157,1735,1736],{"style":167},"[{ ",[157,1738,1329],{"style":163},[157,1740,1720],{"style":171},[157,1742,212],{"style":163},[157,1744,1745],{"style":167},"petstore_auth",[157,1747,70],{"style":163},[157,1749,1750],{"style":167},"scopes",[157,1752,224],{"style":163},[157,1754,900],{"style":167},[157,1756,1757],{"style":185},"'write:pets'",[157,1759,1760],{"style":167},"] }]",[1391,1762,760],{"id":1763},"mutual-tls",[11,1765,1766,1767,1770,1771,1773],{},"When the spec has a ",[23,1768,1769],{},"mutualTLS"," scheme, ",[23,1772,1720],{}," leaves it out, because its credential is a client certificate on the connection, not on the request. In Node.js, give an axios instance the certificate:",[148,1775,1777],{"language":150,"code":1776,"class":152},"import { readFileSync } from 'node:fs'\nimport { Agent } from 'node:https'\nimport axios from 'axios'\nimport { client, createAxiosTransport } from '.\u002Fgen\u002F.kubb\u002Fclient'\n\nconst instance = axios.create({ httpsAgent: new Agent({ cert: readFileSync('client.crt'), key: readFileSync('client.key') }) })\n\nclient.setConfig({ transport: createAxiosTransport(instance) })",[23,1778,1779,187,1795,187,1811,187,1823,187,1842,187,1844,187,1907,187,1909],{"class":155},[157,1780,1781,1783,1785,1788,1790,1792],{"class":159,"style":160},[157,1782,164],{"style":163},[157,1784,168],{"style":167},[157,1786,1787],{"style":171},"readFileSync ",[157,1789,179],{"style":167},[157,1791,182],{"style":163},[157,1793,1794],{"style":185},"'node:fs'",[157,1796,1797,1799,1801,1804,1806,1808],{"class":159,"style":160},[157,1798,164],{"style":163},[157,1800,168],{"style":167},[157,1802,1803],{"style":215},"Agent ",[157,1805,179],{"style":167},[157,1807,182],{"style":163},[157,1809,1810],{"style":185},"'node:https'",[157,1812,1813,1815,1818,1820],{"class":159,"style":160},[157,1814,164],{"style":163},[157,1816,1817],{"style":171},"axios ",[157,1819,182],{"style":163},[157,1821,1822],{"style":185},"'axios'",[157,1824,1825,1827,1829,1831,1833,1836,1838,1840],{"class":159,"style":160},[157,1826,164],{"style":163},[157,1828,168],{"style":167},[157,1830,25],{"style":171},[157,1832,70],{"style":163},[157,1834,1835],{"style":171},"createAxiosTransport ",[157,1837,179],{"style":167},[157,1839,182],{"style":163},[157,1841,186],{"style":185},[157,1843],{"class":159,"style":160},[157,1845,1846,1848,1851,1853,1856,1858,1861,1863,1866,1868,1870,1873,1875,1878,1880,1883,1885,1888,1890,1892,1895,1897,1899,1901,1904],{"class":159,"style":160},[157,1847,268],{"style":163},[157,1849,1850],{"style":171},"instance ",[157,1852,274],{"style":163},[157,1854,1855],{"style":171},"axios",[157,1857,212],{"style":163},[157,1859,1860],{"style":215},"create",[157,1862,219],{"style":167},[157,1864,1865],{"style":167},"httpsAgent",[157,1867,224],{"style":163},[157,1869,1178],{"style":163},[157,1871,1872],{"style":215},"Agent",[157,1874,219],{"style":167},[157,1876,1877],{"style":167},"cert",[157,1879,224],{"style":163},[157,1881,1882],{"style":215},"readFileSync",[157,1884,531],{"style":167},[157,1886,1887],{"style":185},"'client.crt'",[157,1889,584],{"style":167},[157,1891,70],{"style":163},[157,1893,1894],{"style":167},"key",[157,1896,224],{"style":163},[157,1898,1882],{"style":215},[157,1900,531],{"style":167},[157,1902,1903],{"style":185},"'client.key'",[157,1905,1906],{"style":167},") }) })",[157,1908],{"class":159,"style":160},[157,1910,1911,1913,1915,1917,1919,1921,1923,1926,1928,1931],{"class":159,"style":160},[157,1912,25],{"style":171},[157,1914,212],{"style":163},[157,1916,216],{"style":215},[157,1918,219],{"style":167},[157,1920,135],{"style":167},[157,1922,224],{"style":163},[157,1924,1925],{"style":215},"createAxiosTransport",[157,1927,531],{"style":167},[157,1929,1930],{"style":171},"instance",[157,1932,1933],{"style":167},") })",[11,1935,1936],{},"In the browser, the browser picks the client certificate itself.",[1391,1938,1511],{"id":1939},"interceptor-order",[11,1941,1942,1943,1947,1948,146],{},"When you register ",[452,1944,1946],{"href":1945},"#native-axios-interceptors","native axios interceptors"," next to ",[23,1949,769],{},[1951,1952,1953,1961,1964],"ul",{},[1954,1955,1956,1957,1960],"li",{},"Native request interceptors run after the ",[23,1958,1959],{},"client.interceptors.request"," handlers, in reverse order of registration, as axios runs them.",[1954,1962,1963],{},"Native response interceptors see the raw bytes, before Kubb decodes them.",[1954,1965,1966,1967,1969],{},"An instance you pass to ",[23,1968,1925],{}," keeps its own interceptors.",{"title":1971,"searchDepth":1972,"depth":1972,"links":1973},"",5,[1974,1976,1977,1978,1982],{"id":17,"depth":1975,"text":18},2,{"id":380,"depth":1975,"text":381},{"id":487,"depth":1975,"text":488},{"id":763,"depth":1975,"text":764,"children":1979},[1980],{"id":1393,"depth":1981,"text":1394},3,{"id":1521,"depth":1975,"text":1522,"children":1983},[1984,1985,1986,1987,1988],{"id":1525,"depth":1981,"text":479},{"id":1571,"depth":1981,"text":484},{"id":1699,"depth":1981,"text":756},{"id":1763,"depth":1981,"text":760},{"id":1939,"depth":1981,"text":1511},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios\u002Fguides\u002Fconfigure-requests",1794776436432]