[{"data":1,"prerenderedAt":694},["ShallowReactive",2],{"navigation":3,"-guide-fetch":225,"-guide-fetch-surround":690},[4,76,219],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Docs","/guide","1.guide/0.index",[9,11,16,21,26,31,36,41,46,51,56,61,66,71],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"Server Utils","/guide/utils","1.guide/1.utils","ri:tools-line",{"title":17,"path":18,"stem":19,"icon":20},"Tasks","/guide/tasks","1.guide/10.tasks","codicon:run-all",{"title":22,"path":23,"stem":24,"icon":25},"Server Routes","/guide/routing","1.guide/2.routing","ri:direction-line",{"title":27,"path":28,"stem":29,"icon":30},"WebSocket","/guide/websocket","1.guide/3.websocket","cib:socket-io",{"title":32,"path":33,"stem":34,"icon":35},"KV Storage","/guide/storage","1.guide/4.storage","carbon:datastore",{"title":37,"path":38,"stem":39,"icon":40},"SQL Database","/guide/database","1.guide/5.database","ri:database-2-line",{"title":42,"path":43,"stem":44,"icon":45},"Cache","/guide/cache","1.guide/6.cache","ri:speed-line",{"title":47,"path":48,"stem":49,"icon":50},"Fetch","/guide/fetch","1.guide/7.fetch","ri:global-line",{"title":52,"path":53,"stem":54,"icon":55},"Assets","/guide/assets","1.guide/8.assets","ri:image-2-line",{"title":57,"path":58,"stem":59,"icon":60},"Plugins","/guide/plugins","1.guide/9.plugins","ri:plug-line",{"title":62,"path":63,"stem":64,"icon":65},"Configuration","/guide/configuration","1.guide/97.configuration","ri:settings-3-line",{"title":67,"path":68,"stem":69,"icon":70},"TypeScript","/guide/typescript","1.guide/98.typescript","tabler:brand-typescript",{"title":72,"path":73,"stem":74,"icon":75},"Nightly Channel","/guide/nightly","1.guide/99.nightly","ri:moon-fill",{"title":77,"path":78,"stem":79,"children":80,"icon":82},"Deploy","/deploy","2.deploy/0.index",[81,83,87,113,118],{"title":77,"path":78,"stem":79,"icon":82},"ri:upload-cloud-2-line",{"title":84,"path":85,"stem":86,"icon":50},"Edge Workers","/deploy/workers","2.deploy/1.workers",{"title":88,"path":89,"stem":90,"children":91,"page":112},"Runtimes","/deploy/runtimes","2.deploy/10.runtimes",[92,97,102,107],{"title":93,"path":94,"stem":95,"icon":96},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":98,"path":99,"stem":100,"icon":101},"WinterJS","/deploy/runtimes/_winterjs","2.deploy/10.runtimes/_winterjs","game-icons:cold-heart",{"title":103,"path":104,"stem":105,"icon":106},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":108,"path":109,"stem":110,"icon":111},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":114,"path":115,"stem":116,"icon":117},"Custom Preset","/deploy/custom-presets","2.deploy/2.custom-presets","ri:file-code-line",{"title":119,"path":120,"stem":121,"children":122,"page":112},"Providers","/deploy/providers","2.deploy/20.providers",[123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215],{"title":124,"path":125,"stem":126},"Alwaysdata","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":128,"path":129,"stem":130},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":132,"path":133,"stem":134},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":136,"path":137,"stem":138},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":140,"path":141,"stem":142},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":144,"path":145,"stem":146},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":148,"path":149,"stem":150},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":152,"path":153,"stem":154},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":156,"path":157,"stem":158},"Edgio","/deploy/providers/edgio","2.deploy/20.providers/edgio",{"title":160,"path":161,"stem":162},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":164,"path":165,"stem":166},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":168,"path":169,"stem":170},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":172,"path":173,"stem":174},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":176,"path":177,"stem":178},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":180,"path":181,"stem":182},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":184,"path":185,"stem":186},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":188,"path":189,"stem":190},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":192,"path":193,"stem":194},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":196,"path":197,"stem":198},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":200,"path":201,"stem":202},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":204,"path":205,"stem":206},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":208,"path":209,"stem":210},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":212,"path":213,"stem":214},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":216,"path":217,"stem":218},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":220,"path":221,"stem":222,"children":223,"icon":65},"Config","/config","3.config/0.index",[224],{"title":220,"path":221,"stem":222,"icon":65},{"id":226,"title":47,"body":227,"description":684,"extension":685,"meta":686,"navigation":687,"path":48,"seo":688,"stem":49,"__hash__":689},"content/1.guide/7.fetch.md",{"type":228,"value":229,"toc":680,"icon":50},"minimark",[230,235,244,343,349,435,441,583,597,601,607,667,676],[231,232,234],"h2",{"id":233},"usage","Usage",[236,237,238,239,243],"p",{},"In your handler, you just have to call the ",[240,241,242],"code",{},"$fetch"," function to make a request. The response will be automatically parsed.",[245,246,252],"pre",{"className":247,"code":248,"filename":249,"language":250,"meta":251,"style":251},"language-ts shiki shiki-themes github-light github-dark github-dark","export default defineEventHandler(async (event) => {\n  const data = await $fetch('https://ungh.cc/orgs/unjs/repos')\n\n  return data\n})\n","Router Handler","ts","",[240,253,254,293,321,328,337],{"__ignoreMap":251},[255,256,259,263,266,270,274,277,280,284,287,290],"span",{"class":257,"line":258},"line",1,[255,260,262],{"class":261},"so5gQ","export",[255,264,265],{"class":261}," default",[255,267,269],{"class":268},"shcOC"," defineEventHandler",[255,271,273],{"class":272},"slsVL","(",[255,275,276],{"class":261},"async",[255,278,279],{"class":272}," (",[255,281,283],{"class":282},"sQHwn","event",[255,285,286],{"class":272},") ",[255,288,289],{"class":261},"=>",[255,291,292],{"class":272}," {\n",[255,294,296,299,303,306,309,312,314,318],{"class":257,"line":295},2,[255,297,298],{"class":261},"  const",[255,300,302],{"class":301},"suiK_"," data",[255,304,305],{"class":261}," =",[255,307,308],{"class":261}," await",[255,310,311],{"class":268}," $fetch",[255,313,273],{"class":272},[255,315,317],{"class":316},"sfrk1","'https://ungh.cc/orgs/unjs/repos'",[255,319,320],{"class":272},")\n",[255,322,324],{"class":257,"line":323},3,[255,325,327],{"emptyLinePlaceholder":326},true,"\n",[255,329,331,334],{"class":257,"line":330},4,[255,332,333],{"class":261},"  return",[255,335,336],{"class":272}," data\n",[255,338,340],{"class":257,"line":339},5,[255,341,342],{"class":272},"})\n",[236,344,345,346,348],{},"You can pass a generic type to the ",[240,347,242],{}," function to get a better type inference.",[245,350,352],{"className":247,"code":351,"filename":249,"language":250,"meta":251,"style":251},"import { Repo } from '~/types'\n\nexport default defineEventHandler(async (event) => {\n  const data = await $fetch\u003CRepo[]>('https://ungh.cc/orgs/unjs/repos')\n\n  return data\n})\n",[240,353,354,368,372,394,419,423,430],{"__ignoreMap":251},[255,355,356,359,362,365],{"class":257,"line":258},[255,357,358],{"class":261},"import",[255,360,361],{"class":272}," { Repo } ",[255,363,364],{"class":261},"from",[255,366,367],{"class":316}," '~/types'\n",[255,369,370],{"class":257,"line":295},[255,371,327],{"emptyLinePlaceholder":326},[255,373,374,376,378,380,382,384,386,388,390,392],{"class":257,"line":323},[255,375,262],{"class":261},[255,377,265],{"class":261},[255,379,269],{"class":268},[255,381,273],{"class":272},[255,383,276],{"class":261},[255,385,279],{"class":272},[255,387,283],{"class":282},[255,389,286],{"class":272},[255,391,289],{"class":261},[255,393,292],{"class":272},[255,395,396,398,400,402,404,406,409,412,415,417],{"class":257,"line":330},[255,397,298],{"class":261},[255,399,302],{"class":301},[255,401,305],{"class":261},[255,403,308],{"class":261},[255,405,311],{"class":268},[255,407,408],{"class":272},"\u003C",[255,410,411],{"class":268},"Repo",[255,413,414],{"class":272},"[]>(",[255,416,317],{"class":316},[255,418,320],{"class":272},[255,420,421],{"class":257,"line":339},[255,422,327],{"emptyLinePlaceholder":326},[255,424,426,428],{"class":257,"line":425},6,[255,427,333],{"class":261},[255,429,336],{"class":272},[255,431,433],{"class":257,"line":432},7,[255,434,342],{"class":272},[236,436,437,438,440],{},"You can pass many options to the ",[240,439,242],{}," function like the method, headers, body, query, etc.",[245,442,444],{"className":247,"code":443,"filename":249,"language":250,"meta":251,"style":251},"import { Repo } from '~/types'\n\nexport default defineEventHandler(async (event) => {\n  const data = await $fetch\u003CRepo[]>('https://api.github.com/markdown', {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/json'\n    },\n    body: {\n      text: 'Hello **world**!'\n    }\n  })\n\n  return data\n})\n",[240,445,446,456,460,482,506,517,522,533,539,545,554,560,566,571,578],{"__ignoreMap":251},[255,447,448,450,452,454],{"class":257,"line":258},[255,449,358],{"class":261},[255,451,361],{"class":272},[255,453,364],{"class":261},[255,455,367],{"class":316},[255,457,458],{"class":257,"line":295},[255,459,327],{"emptyLinePlaceholder":326},[255,461,462,464,466,468,470,472,474,476,478,480],{"class":257,"line":323},[255,463,262],{"class":261},[255,465,265],{"class":261},[255,467,269],{"class":268},[255,469,273],{"class":272},[255,471,276],{"class":261},[255,473,279],{"class":272},[255,475,283],{"class":282},[255,477,286],{"class":272},[255,479,289],{"class":261},[255,481,292],{"class":272},[255,483,484,486,488,490,492,494,496,498,500,503],{"class":257,"line":330},[255,485,298],{"class":261},[255,487,302],{"class":301},[255,489,305],{"class":261},[255,491,308],{"class":261},[255,493,311],{"class":268},[255,495,408],{"class":272},[255,497,411],{"class":268},[255,499,414],{"class":272},[255,501,502],{"class":316},"'https://api.github.com/markdown'",[255,504,505],{"class":272},", {\n",[255,507,508,511,514],{"class":257,"line":339},[255,509,510],{"class":272},"    method: ",[255,512,513],{"class":316},"'POST'",[255,515,516],{"class":272},",\n",[255,518,519],{"class":257,"line":425},[255,520,521],{"class":272},"    headers: {\n",[255,523,524,527,530],{"class":257,"line":432},[255,525,526],{"class":316},"      'Content-Type'",[255,528,529],{"class":272},": ",[255,531,532],{"class":316},"'application/json'\n",[255,534,536],{"class":257,"line":535},8,[255,537,538],{"class":272},"    },\n",[255,540,542],{"class":257,"line":541},9,[255,543,544],{"class":272},"    body: {\n",[255,546,548,551],{"class":257,"line":547},10,[255,549,550],{"class":272},"      text: ",[255,552,553],{"class":316},"'Hello **world**!'\n",[255,555,557],{"class":257,"line":556},11,[255,558,559],{"class":272},"    }\n",[255,561,563],{"class":257,"line":562},12,[255,564,565],{"class":272},"  })\n",[255,567,569],{"class":257,"line":568},13,[255,570,327],{"emptyLinePlaceholder":326},[255,572,574,576],{"class":257,"line":573},14,[255,575,333],{"class":261},[255,577,336],{"class":272},[255,579,581],{"class":257,"line":580},15,[255,582,342],{"class":272},[236,584,585,586,588,589,596],{},"See more about the usage of the ",[240,587,242],{}," function in the ",[590,591,595],"a",{"href":592,"rel":593},"https://ofetch.unjs.io",[594],"nofollow","ofetch"," documentation.",[231,598,600],{"id":599},"in-server-fetch","In-Server fetch",[236,602,603,604,606],{},"You can also use the ",[240,605,242],{}," function to make internal requests to other handlers.",[245,608,610],{"className":247,"code":609,"filename":249,"language":250,"meta":251,"style":251},"export default defineEventHandler(async (event) => {\n  const data = await $fetch('/api/users')\n\n  return data\n})\n",[240,611,612,634,653,657,663],{"__ignoreMap":251},[255,613,614,616,618,620,622,624,626,628,630,632],{"class":257,"line":258},[255,615,262],{"class":261},[255,617,265],{"class":261},[255,619,269],{"class":268},[255,621,273],{"class":272},[255,623,276],{"class":261},[255,625,279],{"class":272},[255,627,283],{"class":282},[255,629,286],{"class":272},[255,631,289],{"class":261},[255,633,292],{"class":272},[255,635,636,638,640,642,644,646,648,651],{"class":257,"line":295},[255,637,298],{"class":261},[255,639,302],{"class":301},[255,641,305],{"class":261},[255,643,308],{"class":261},[255,645,311],{"class":268},[255,647,273],{"class":272},[255,649,650],{"class":316},"'/api/users'",[255,652,320],{"class":272},[255,654,655],{"class":257,"line":323},[255,656,327],{"emptyLinePlaceholder":326},[255,658,659,661],{"class":257,"line":330},[255,660,333],{"class":261},[255,662,336],{"class":272},[255,664,665],{"class":257,"line":339},[255,666,342],{"class":272},[236,668,669,670,675],{},"In reality, no fetch request is made and the handler is directly called, thanks to ",[590,671,674],{"href":672,"rel":673},"https://unenv.unjs.io",[594],"unenv",". This is useful to avoid making HTTP request overhead.",[677,678,679],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}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 .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-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);}",{"title":251,"searchDepth":295,"depth":295,"links":681},[682,683],{"id":233,"depth":295,"text":234},{"id":599,"depth":295,"text":600},"Nitro provides a built-in fetch API that can be used to get data from server endpoints or from other sources. It's built on top of the ofetch.","md",{"icon":50},{"icon":50},{"title":47,"description":684},"KKlVBsm5eP206ltHqKvIHzxVt6iaiELrj-HDdmL1GdA",[691,693],{"title":42,"path":43,"stem":44,"description":692,"icon":45,"children":-1},"Nitro provides a caching system built on top of the storage layer.",{"title":52,"path":53,"stem":54,"description":251,"icon":55,"children":-1},1775118356727]