{"id":20099,"date":"2026-08-31T00:00:00","date_gmt":"2026-08-31T00:00:00","guid":{"rendered":"https:\/\/withcode.tech\/media\/?p=20099"},"modified":"2026-09-01T15:53:16","modified_gmt":"2026-09-01T15:53:16","slug":"javascript-fetch-api","status":"publish","type":"post","link":"https:\/\/withcode.tech\/media\/javascript-fetch-api\/","title":{"rendered":"fetch API\u306e\u4f7f\u3044\u65b9\uff5c\u975e\u540c\u671f\u901a\u4fe1\u306e\u57fa\u672c\u304b\u3089\u30a8\u30e9\u30fc\u51e6\u7406\u307e\u3067"},"content":{"rendered":"<div class=\"swell-block-balloon\">\n<div class=\"c-balloon -bln-left\" data-col=\"gray\">\n<div class=\"c-balloon__icon -square\"><img decoding=\"async\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-14.40.37.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u751f\u5f92<\/span><\/div>\n<div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\"><p><strong>API\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u3063\u3066\u304d\u3066\u753b\u9762\u306b\u51fa\u3057\u305f\u3044\u3093\u3067\u3059\u304c\u3001fetch\u306e\u66f8\u304d\u65b9\u304c\u3044\u307e\u3044\u3061\u63b4\u3081\u307e\u305b\u3093\u2026\u3002<\/strong><\/p><span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div>\n<\/div>\n<\/div>\n\n<div class=\"swell-block-balloon\">\n<div class=\"c-balloon -bln-right\" data-col=\"gray\">\n<div class=\"c-balloon__icon -square\"><img decoding=\"async\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-15.11.23.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u30da\u30f3\u535a\u58eb<\/span><\/div>\n<div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\"><p><strong>fetch\u306f<strong>\u300c\u6295\u3052\u308b\u30fb\u5f85\u3064\u30fb\u53d7\u3051\u53d6\u308b\u300d\u306e3\u6bb5\u968e<\/strong>\u3067\u8003\u3048\u308b\u3068\u7c21\u5358\u3060\u3088\u3002async\/await\u3067\u66f8\u3051\u3070\u898b\u305f\u76ee\u3082\u307b\u307c\u540c\u671f\u51e6\u7406\u3068\u540c\u3058\u306b\u306a\u308b\u3002\u843d\u3068\u3057\u7a74\u306e\u30a8\u30e9\u30fc\u51e6\u7406\u307e\u3067\u9806\u756a\u306b\u898b\u3066\u3044\u3053\u3046\u3002<\/strong><\/p><span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div>\n<\/div>\n<\/div>\n\n<p class=\"wp-block-paragraph\">\u5916\u90e8\u306eAPI\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u5185\u5bb9\u3092\u30b5\u30fc\u30d0\u30fc\u3078\u9001\u308b\u3001\u30da\u30fc\u30b8\u3092\u518d\u8aad\u307f\u8fbc\u307f\u305b\u305a\u306b\u4e00\u89a7\u3092\u66f4\u65b0\u3059\u308b\u3002\u3053\u3046\u3057\u305f\u51e6\u7406\u306e\u5165\u53e3\u304c<span class=\"swl-marker mark_yellow\">fetch API<\/span>\u3067\u3059\u3002<\/p>\n\n<p class=\"wp-block-paragraph\">\u304b\u3064\u3066\u306f<code>XMLHttpRequest<\/code>\u3068\u3044\u3046\u9577\u3044\u8a18\u8ff0\u304c\u5fc5\u8981\u3067\u3057\u305f\u304c\u3001fetch\u306a\u3089\u6570\u884c\u3067\u66f8\u3051\u307e\u3059\u3002\u30d6\u30e9\u30a6\u30b6\u306b\u6a19\u6e96\u642d\u8f09\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\u3082\u4e0d\u8981\u3067\u3059\u3002<\/p>\n\n<p class=\"wp-block-paragraph\">\u305f\u3060\u30571\u3064\u3060\u3051\u6709\u540d\u306a\u843d\u3068\u3057\u7a74\u304c\u3042\u308a\u307e\u3059\u3002<strong>404\u3084500\u304c\u8fd4\u3063\u3066\u304d\u3066\u3082catch\u306b\u5165\u3089\u306a\u3044<\/strong>\u3068\u3044\u3046\u6319\u52d5\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u57fa\u672c\u306e\u66f8\u304d\u65b9\u304b\u3089\u3001\u305d\u306e\u5bfe\u51e6\u3001\u5b9f\u52d9\u3067\u5fc5\u8981\u306b\u306a\u308b\u30a8\u30e9\u30fc\u51e6\u7406\u30fb\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u30fb\u4e26\u5217\u53d6\u5f97\u307e\u3067\u307e\u3068\u3081\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n<ul class=\"wp-block-list\">\n<li>fetch\u306e\u57fa\u672c\u69cb\u6587\uff083\u3064\u306e\u30b9\u30c6\u30c3\u30d7\uff09<\/li>\n<li>async\/await\u3067\u8aad\u307f\u3084\u3059\u304f\u66f8\u304f<\/li>\n<li>404\u30fb500\u304ccatch\u3055\u308c\u306a\u3044\u554f\u984c\u3068\u5bfe\u51e6<\/li>\n<li>GET\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li>POST\u3067\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b<\/li>\n<li>JSON\u4ee5\u5916\uff08\u30c6\u30ad\u30b9\u30c8\u30fb\u753b\u50cf\u30fbFormData\uff09\u306e\u6271\u3044<\/li>\n<li>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3068\u4e2d\u65ad\uff08AbortController\uff09<\/li>\n<li>\u8907\u6570\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4e26\u5217\u3067\u51e6\u7406\u3059\u308b<\/li>\n<li>CORS\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3068\u5bfe\u51e6<\/li>\n<li>\u5b9f\u52d9\u3067\u4f7f\u3048\u308b\u6c4e\u7528\u95a2\u6570<\/li>\n<\/ul>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h2 class=\"wp-block-heading\">fetch\u306e\u57fa\u672c\u69cb\u6587<\/h2>\n\n<figure class=\"wp-block-image size-large\" data-dia=\"20099-1\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-01-2.jpg\" alt=\"fetch\u306e\u57fa\u672c\u69cb\u6587\" class=\"wp-image-20448\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-01-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-01-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-01-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">fetch\u306f\u300c\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u308b\u300d\u300c\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d7\u3051\u53d6\u308b\u300d\u300c\u4e2d\u8eab\u3092\u53d6\u308a\u51fa\u3059\u300d\u306e3\u6bb5\u968e\u3067\u52d5\u304d\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u6700\u5c0f\u306e\u66f8\u304d\u65b9\nfetch('https:\/\/api.example.com\/posts')\n  .then(response =&gt; response.json())   \/\/ \u4e2d\u8eab\u3092JSON\u3068\u3057\u3066\u53d6\u308a\u51fa\u3059\n  .then(data =&gt; console.log(data))     \/\/ \u53d6\u308a\u51fa\u3057\u305f\u7d50\u679c\u3092\u4f7f\u3046\n  .catch(error =&gt; console.error(error));<\/code><\/pre><\/div>\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u6bb5\u968e<\/th><th>\u4f55\u3092\u3057\u3066\u3044\u308b<\/th><th>\u623b\u308a\u5024<\/th><\/tr><\/thead>\n<tbody>\n<tr><td><code>fetch(url)<\/code><\/td><td>\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308b<\/td><td>Response\u3092\u542b\u3080Promise<\/td><\/tr>\n<tr><td><code>response.json()<\/code><\/td><td>\u672c\u6587\u3092JSON\u306b\u5909\u63db<\/td><td>\u30c7\u30fc\u30bf\u3092\u542b\u3080Promise<\/td><\/tr>\n<tr><td><code>data<\/code><\/td><td>\u5b9f\u969b\u306e\u5024\u3092\u4f7f\u3046<\/td><td>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3084\u914d\u5217<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n<p class=\"wp-block-paragraph\">\u91cd\u8981\u306a\u306e\u306f\u3001fetch\u304c\u8fd4\u3059\u306e\u304c<span class=\"swl-marker mark_yellow\">\u30c7\u30fc\u30bf\u305d\u306e\u3082\u306e\u3067\u306f\u306a\u304fResponse\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/span>\u3060\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3084\u30d8\u30c3\u30c0\u30fc\u306e\u60c5\u5831\u304c\u5165\u3063\u3066\u304a\u308a\u3001\u672c\u6587\u306f<code>.json()<\/code>\u306a\u3069\u3067\u5225\u9014\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">async\/await\u3067\u8aad\u307f\u3084\u3059\u304f\u66f8\u304f<\/h2>\n\n<p class=\"wp-block-paragraph\"><code>.then()<\/code>\u306e\u9023\u9396\u306f\u51e6\u7406\u304c\u5897\u3048\u308b\u3068\u8aad\u307f\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002\u5b9f\u52d9\u3067\u306fasync\/await\u3067\u66f8\u304f\u306e\u304c\u4e3b\u6d41\u3067\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>async function getPosts() {\n  try {\n    const response = await fetch('https:\/\/api.example.com\/posts');\n    const data = await response.json();\n    console.log(data);\n    return data;\n  } catch (error) {\n    console.error('\u53d6\u5f97\u306b\u5931\u6557\u3057\u307e\u3057\u305f:', error);\n  }\n}\n\ngetPosts();<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>await<\/code>\u306f\u300c\u3053\u306e\u884c\u304c\u7d42\u308f\u308b\u307e\u3067\u5f85\u3064\u300d\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002\u4e0a\u304b\u3089\u4e0b\u3078\u9806\u306b\u8aad\u3081\u308b\u305f\u3081\u3001\u51e6\u7406\u306e\u6d41\u308c\u304c\u305d\u306e\u307e\u307e\u30b3\u30fc\u30c9\u306e\u4e26\u3073\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001<code>await<\/code>\u306f<span class=\"swl-marker mark_yellow\">async\u95a2\u6570\u306e\u4e2d\u3067\u3057\u304b\u4f7f\u3048\u307e\u305b\u3093<\/span>\u3002\u95a2\u6570\u306e\u5916\u3067\u4f7f\u3046\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\uff08\u30e2\u30b8\u30e5\u30fc\u30eb\u76f4\u4e0b\u306e\u30c8\u30c3\u30d7\u30ec\u30d9\u30ebawait\u306f\u4f8b\u5916\uff09\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">404\u30fb500\u304ccatch\u3055\u308c\u306a\u3044\u554f\u984c<\/h2>\n\n<figure class=\"wp-block-image size-large\" data-dia=\"20099-2\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-02-2.jpg\" alt=\"404\u30fb500\u304ccatch\u3055\u308c\u306a\u3044\u554f\u984c\" class=\"wp-image-20449\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-02-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-02-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-02-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">fetch\u6700\u5927\u306e\u843d\u3068\u3057\u7a74\u3067\u3059\u3002\u30b5\u30fc\u30d0\u30fc\u304c404\u3084500\u3092\u8fd4\u3057\u3066\u3082\u3001\u901a\u4fe1\u81ea\u4f53\u306f\u6210\u529f\u3057\u3066\u3044\u308b\u305f\u3081catch\u306b\u5165\u308a\u307e\u305b\u3093\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u5371\u967a\u306a\u66f8\u304d\u65b9\uff1a404\u3067\u3082\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\nasync function bad() {\n  try {\n    const res = await fetch('https:\/\/api.example.com\/not-found'); \/\/ 404\n    const data = await res.json();   \/\/ \u3053\u3053\u3067JSON\u89e3\u6790\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3053\u3068\u3082\n    console.log(data);\n  } catch (e) {\n    console.error(e);   \/\/ \u671f\u5f85\u3057\u305f\u5834\u6240\u3067\u6355\u307e\u3089\u306a\u3044\n  }\n}<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">catch\u306b\u5165\u308b\u306e\u306f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u65ad\u30fbCORS\u9055\u53cd\u30fbURL\u304c\u4e0d\u6b63\u3068\u3044\u3063\u305f<strong>\u901a\u4fe1\u81ea\u4f53\u304c\u5931\u6557\u3057\u305f\u5834\u5408\u3060\u3051<\/strong>\u3067\u3059\u3002HTTP\u30b9\u30c6\u30fc\u30bf\u30b9\u306f\u81ea\u5206\u3067\u5224\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u6b63\u3057\u3044\u66f8\u304d\u65b9\uff1ares.ok \u3092\u5fc5\u305a\u78ba\u8a8d\u3059\u308b\nasync function getPosts() {\n  const res = await fetch('https:\/\/api.example.com\/posts');\n\n  if (!res.ok) {\n    \/\/ 200\u301c299\u4ee5\u5916\u306f\u3053\u3053\u3067\u5f3e\u304f\n    throw new Error(`HTTP\u30a8\u30e9\u30fc: ${res.status} ${res.statusText}`);\n  }\n\n  return await res.json();\n}<\/code><\/pre><\/div>\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u72b6\u6cc1<\/th><th>catch\u306b\u5165\u308b\uff1f<\/th><th>\u5224\u5b9a\u65b9\u6cd5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u901a\u4fe1\u65ad\u30fb\u30aa\u30d5\u30e9\u30a4\u30f3<\/td><td>\u5165\u308b<\/td><td>catch\u3067\u6355\u307e\u3048\u308b<\/td><\/tr>\n<tr><td>CORS\u9055\u53cd<\/td><td>\u5165\u308b<\/td><td>catch\u3067\u6355\u307e\u3048\u308b<\/td><\/tr>\n<tr><td>404 Not Found<\/td><td>\u5165\u3089\u306a\u3044<\/td><td><code>res.ok<\/code>\u3067\u5224\u5b9a<\/td><\/tr>\n<tr><td>500 \u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc<\/td><td>\u5165\u3089\u306a\u3044<\/td><td><code>res.ok<\/code>\u3067\u5224\u5b9a<\/td><\/tr>\n<tr><td>JSON\u306e\u5f62\u5f0f\u304c\u4e0d\u6b63<\/td><td>\u5165\u308b<\/td><td><code>.json()<\/code>\u3067\u4f8b\u5916<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n<p class=\"wp-block-paragraph\"><code>res.ok<\/code>\u306f<span class=\"swl-marker mark_yellow\">\u30b9\u30c6\u30fc\u30bf\u30b9\u304c200\u301c299\u306e\u3068\u304dtrue<\/span>\u306b\u306a\u308b\u4fbf\u5229\u306a\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3059\u3002fetch\u3092\u66f8\u3044\u305f\u3089\u5fc5\u305a\u3053\u306e\u5224\u5b9a\u3092\u5165\u308c\u308b\u3001\u3068\u899a\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">GET\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<\/h2>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-03-2.jpg\" alt=\"GET\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\" class=\"wp-image-20450\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-03-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-03-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-03-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">\u6700\u3082\u3088\u304f\u4f7f\u3046\u5f62\u3067\u3059\u3002\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092DOM\u306b\u53cd\u6620\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u901a\u3057\u3067\u66f8\u304d\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>async function renderPosts() {\n  const list = document.querySelector('#post-list');\n  list.textContent = '\u8aad\u307f\u8fbc\u307f\u4e2d\u2026';\n\n  try {\n    const res = await fetch('https:\/\/api.example.com\/posts?limit=10');\n    if (!res.ok) throw new Error(`HTTP\u30a8\u30e9\u30fc: ${res.status}`);\n\n    const posts = await res.json();\n\n    \/\/ \u4e00\u5ea6\u306b\u7d44\u307f\u7acb\u3066\u3066\u304b\u3089\u5dee\u3057\u8fbc\u3080\uff08\u63cf\u753b\u56de\u6570\u3092\u6e1b\u3089\u3059\uff09\n    list.innerHTML = posts\n      .map(post =&gt; `&lt;li&gt;&lt;a href=\"${post.url}\"&gt;${post.title}&lt;\/a&gt;&lt;\/li&gt;`)\n      .join('');\n  } catch (error) {\n    list.textContent = '\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u6642\u9593\u3092\u304a\u3044\u3066\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002';\n    console.error(error);\n  }\n}\n\ndocument.addEventListener('DOMContentLoaded', renderPosts);<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">\u30af\u30a8\u30ea\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u591a\u3044\u5834\u5408\u306f\u3001\u6587\u5b57\u5217\u3092\u624b\u3067\u9023\u7d50\u305b\u305a<code>URLSearchParams<\/code>\u3092\u4f7f\u3046\u3068\u5b89\u5168\u3067\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>const params = new URLSearchParams({\n  category: 'css',\n  limit: 10,\n  keyword: '\u4e2d\u592e\u5bc4\u305b',    \/\/ \u65e5\u672c\u8a9e\u3082\u81ea\u52d5\u3067\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u308b\n});\n\nconst res = await fetch(`https:\/\/api.example.com\/posts?${params}`);<\/code><\/pre><\/div>\n\n<h2 class=\"wp-block-heading\">POST\u3067\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b<\/h2>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-04-2.jpg\" alt=\"POST\u3067\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\" class=\"wp-image-20451\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-04-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-04-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-04-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">\u9001\u4fe1\u3067\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u30fb\u30d8\u30c3\u30c0\u30fc\u30fb\u672c\u6587\u306e3\u3064\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>async function sendContact(formData) {\n  const res = await fetch('https:\/\/api.example.com\/contact', {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application\/json',\n    },\n    body: JSON.stringify({\n      name: formData.name,\n      email: formData.email,\n      message: formData.message,\n    }),\n  });\n\n  if (!res.ok) throw new Error(`\u9001\u4fe1\u306b\u5931\u6557\u3057\u307e\u3057\u305f: ${res.status}`);\n  return await res.json();\n}<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>body<\/code>\u306b\u306f<span class=\"swl-marker mark_yellow\">\u6587\u5b57\u5217\u3092\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<\/span>\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u305d\u306e\u307e\u307e\u6e21\u3057\u3066\u3082\u9001\u4fe1\u3055\u308c\u306a\u3044\u305f\u3081\u3001<code>JSON.stringify()<\/code>\u3067\u5909\u63db\u3057\u307e\u3059\u3002<\/p>\n\n<p class=\"wp-block-paragraph\">\u30d5\u30a9\u30fc\u30e0\u306e\u5024\u3092\u307e\u3068\u3081\u3066\u9001\u308b\u5834\u5408\u306f\u3001<code>FormData<\/code>\u3092\u4f7f\u3046\u3068\u5165\u529b\u6b04\u30921\u3064\u305a\u3064\u62fe\u3046\u5fc5\u8981\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>const form = document.querySelector('#contact-form');\n\nform.addEventListener('submit', async (event) =&gt; {\n  event.preventDefault();   \/\/ \u30da\u30fc\u30b8\u9077\u79fb\u3092\u6b62\u3081\u308b\n\n  const res = await fetch('\/api\/contact', {\n    method: 'POST',\n    body: new FormData(form),   \/\/ Content-Type\u306f\u81ea\u52d5\u3067\u4ed8\u304f\n  });\n\n  if (res.ok) {\n    form.reset();\n    alert('\u9001\u4fe1\u3057\u307e\u3057\u305f');\n  }\n});<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">FormData\u3092\u4f7f\u3046\u3068\u304d\u306f<code>Content-Type<\/code>\u3092\u81ea\u5206\u3067\u66f8\u304d\u307e\u305b\u3093\u3002\u5883\u754c\u6587\u5b57\u5217\u3092\u542b\u3080\u30d8\u30c3\u30c0\u30fc\u3092\u30d6\u30e9\u30a6\u30b6\u304c\u81ea\u52d5\u751f\u6210\u3059\u308b\u305f\u3081\u3001\u624b\u3067\u6307\u5b9a\u3059\u308b\u3068\u58ca\u308c\u307e\u3059\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">JSON\u4ee5\u5916\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046<\/h2>\n\n<p class=\"wp-block-paragraph\">\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u53d6\u308a\u51fa\u3057\u65b9\u306f\u3001\u8fd4\u3063\u3066\u304f\u308b\u5f62\u5f0f\u306b\u3088\u3063\u3066\u5909\u3048\u307e\u3059\u3002<\/p>\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u30e1\u30bd\u30c3\u30c9<\/th><th>\u623b\u308a\u5024<\/th><th>\u4f7f\u3046\u5834\u9762<\/th><\/tr><\/thead>\n<tbody>\n<tr><td><code>.json()<\/code><\/td><td>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30fb\u914d\u5217<\/td><td>API\u5168\u822c<\/td><\/tr>\n<tr><td><code>.text()<\/code><\/td><td>\u6587\u5b57\u5217<\/td><td>HTML\u30fbCSV\u30fb\u30d7\u30ec\u30fc\u30f3\u30c6\u30ad\u30b9\u30c8<\/td><\/tr>\n<tr><td><code>.blob()<\/code><\/td><td>\u30d0\u30a4\u30ca\u30ea<\/td><td>\u753b\u50cf\u30fbPDF\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/td><\/tr>\n<tr><td><code>.formData()<\/code><\/td><td>FormData<\/td><td>\u30d5\u30a9\u30fc\u30e0\u5f62\u5f0f\u306e\u5fdc\u7b54<\/td><\/tr>\n<tr><td><code>.arrayBuffer()<\/code><\/td><td>\u751f\u30d0\u30a4\u30c8\u5217<\/td><td>\u97f3\u58f0\u30fb\u72ec\u81ea\u5f62\u5f0f<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u30c6\u30ad\u30b9\u30c8\u3068\u3057\u3066\u53d6\u5f97\nconst html = await (await fetch('\/parts\/header.html')).text();\n\n\/\/ \u753b\u50cf\u3092\u53d6\u5f97\u3057\u3066\u8868\u793a\u3059\u308b\nconst res = await fetch('\/img\/photo.jpg');\nconst blob = await res.blob();\ndocument.querySelector('#preview').src = URL.createObjectURL(blob);<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u672c\u6587\u306f<span class=\"swl-marker mark_yellow\">\u4e00\u5ea6\u3057\u304b\u8aad\u307f\u53d6\u308c\u307e\u305b\u3093<\/span>\u3002<code>.json()<\/code>\u3092\u547c\u3093\u3060\u3042\u3068\u306b<code>.text()<\/code>\u3092\u547c\u3076\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u4e21\u65b9\u5fc5\u8981\u306a\u3089<code>res.clone()<\/code>\u3067\u8907\u88fd\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3068\u4e2d\u65ad<\/h2>\n\n<figure class=\"wp-block-image size-large\" data-dia=\"20099-3\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-05-2.jpg\" alt=\"\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3068\u4e2d\u65ad\" class=\"wp-image-20452\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-05-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-05-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-05-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">fetch\u306b\u306f\u6a19\u6e96\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u5fdc\u7b54\u304c\u8fd4\u3089\u306a\u3044\u3068\u5f85\u3061\u7d9a\u3051\u308b\u305f\u3081\u3001\u81ea\u5206\u3067\u6253\u3061\u5207\u308a\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>async function fetchWithTimeout(url, options = {}, timeout = 8000) {\n  const controller = new AbortController();\n  const timer = setTimeout(() =&gt; controller.abort(), timeout);\n\n  try {\n    const res = await fetch(url, { ...options, signal: controller.signal });\n    if (!res.ok) throw new Error(`HTTP\u30a8\u30e9\u30fc: ${res.status}`);\n    return await res.json();\n  } catch (error) {\n    if (error.name === 'AbortError') {\n      throw new Error('\u901a\u4fe1\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3057\u307e\u3057\u305f');\n    }\n    throw error;\n  } finally {\n    clearTimeout(timer);   \/\/ \u6210\u529f\u3057\u3066\u3082\u5fc5\u305a\u89e3\u9664\u3059\u308b\n  }\n}<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>AbortController<\/code>\u306f\u4e2d\u65ad\u306b\u3082\u4f7f\u3048\u307e\u3059\u3002\u691c\u7d22\u306e\u5165\u529b\u9014\u4e2d\u3067\u53e4\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6253\u3061\u5207\u308b\u3001\u3068\u3044\u3063\u305f\u51e6\u7406\u304c\u4ee3\u8868\u4f8b\u3067\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>let currentController = null;\n\nasync function search(keyword) {\n  currentController?.abort();          \/\/ \u524d\u306e\u691c\u7d22\u3092\u4e2d\u65ad\n  currentController = new AbortController();\n\n  const res = await fetch(`\/api\/search?q=${encodeURIComponent(keyword)}`, {\n    signal: currentController.signal,\n  });\n  return await res.json();\n}<\/code><\/pre><\/div>\n\n<h2 class=\"wp-block-heading\">\u8907\u6570\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4e26\u5217\u3067\u51e6\u7406\u3059\u308b<\/h2>\n\n<p class=\"wp-block-paragraph\">\u8907\u6570\u306eAPI\u3092\u53e9\u304f\u5834\u5408\u3001\u9806\u756a\u306bawait\u3059\u308b\u3068\u5f85\u3061\u6642\u9593\u304c\u7a4d\u307f\u91cd\u306a\u308a\u307e\u3059\u3002\u540c\u6642\u306b\u6295\u3052\u308c\u3070\u6700\u3082\u9045\u30441\u672c\u306e\u6642\u9593\u3067\u6e08\u307f\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u9045\u3044\u66f8\u304d\u65b9\uff1a\u5408\u8a083\u79d2\u304b\u304b\u308b\nconst a = await fetch('\/api\/a');   \/\/ 1\u79d2\nconst b = await fetch('\/api\/b');   \/\/ 1\u79d2\nconst c = await fetch('\/api\/c');   \/\/ 1\u79d2\n\n\/\/ \u901f\u3044\u66f8\u304d\u65b9\uff1a\u6700\u3082\u9045\u30441\u672c\u3076\u3093\uff08\u7d041\u79d2\uff09\nconst [resA, resB, resC] = await Promise.all([\n  fetch('\/api\/a'),\n  fetch('\/api\/b'),\n  fetch('\/api\/c'),\n]);<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>Promise.all<\/code>\u306f<span class=\"swl-marker mark_yellow\">1\u3064\u3067\u3082\u5931\u6557\u3059\u308b\u3068\u5168\u4f53\u304c\u5931\u6557<\/span>\u3057\u307e\u3059\u3002\u4e00\u90e8\u304c\u5931\u6557\u3057\u3066\u3082\u7d9a\u884c\u3057\u305f\u3044\u5834\u5408\u306f<code>Promise.allSettled<\/code>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>const results = await Promise.allSettled([\n  fetch('\/api\/a').then(r =&gt; r.json()),\n  fetch('\/api\/b').then(r =&gt; r.json()),\n]);\n\nresults.forEach((result, i) =&gt; {\n  if (result.status === 'fulfilled') {\n    console.log(`${i}\u756a\u76ee \u6210\u529f`, result.value);\n  } else {\n    console.warn(`${i}\u756a\u76ee \u5931\u6557`, result.reason);\n  }\n});<\/code><\/pre><\/div>\n\n<h2 class=\"wp-block-heading\">CORS\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3068\u5bfe\u51e6<\/h2>\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1672\" height=\"941\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-06-2.jpg\" alt=\"CORS\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u3068\u5bfe\u51e6\" class=\"wp-image-20453\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-06-2.jpg 1672w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-06-2-768x432.jpg 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/09\/section-06-2-1536x864.jpg 1536w\" sizes=\"(max-width: 1672px) 100vw, 1672px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">fetch\u3067\u3088\u304f\u906d\u9047\u3059\u308b\u306e\u304cCORS\u30a8\u30e9\u30fc\u3067\u3059\u3002\u300c\u5225\u306e\u30c9\u30e1\u30a4\u30f3\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u3001\u76f8\u624b\u30b5\u30fc\u30d0\u30fc\u304c\u8a31\u53ef\u3057\u3066\u3044\u306a\u3044\u300d\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Console\"><code>Access to fetch at 'https:\/\/api.example.com\/data' from origin\n'https:\/\/mysite.com' has been blocked by CORS policy:\nNo 'Access-Control-Allow-Origin' header is present on the requested resource.<\/code><\/pre><\/div>\n\n<ul class=\"wp-block-list\">\n<li><strong>\u539f\u56e0<\/strong>\uff1aAPI\u30b5\u30fc\u30d0\u30fc\u5074\u304c\u8a31\u53ef\u30d8\u30c3\u30c0\u30fc\u3092\u8fd4\u3057\u3066\u3044\u306a\u3044<\/li>\n<li><strong>\u8aa4\u89e3<\/strong>\uff1aJavaScript\u5074\u306e\u66f8\u304d\u65b9\u3067\u306f\u89e3\u6c7a\u3067\u304d\u306a\u3044<\/li>\n<li><strong>\u5bfe\u51e61<\/strong>\uff1aAPI\u306e\u63d0\u4f9b\u5143\u3067\u8a31\u53ef\u8a2d\u5b9a\u3092\u884c\u3046\uff08\u81ea\u793eAPI\u306e\u5834\u5408\uff09<\/li>\n<li><strong>\u5bfe\u51e62<\/strong>\uff1a\u81ea\u5206\u306e\u30b5\u30fc\u30d0\u30fc\u3092\u7d4c\u7531\u3055\u305b\u308b\uff08\u30d7\u30ed\u30ad\u30b7\uff09<\/li>\n<li><strong>\u5bfe\u51e63<\/strong>\uff1aAPI\u30ad\u30fc\u304c\u5fc5\u8981\u306a\u3082\u306e\u306f\u3001\u305d\u3082\u305d\u3082\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u76f4\u63a5\u53e9\u304b\u306a\u3044<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">\u3088\u304f\u898b\u304b\u3051\u308b<code>mode: 'no-cors'<\/code>\u306f<span class=\"swl-marker mark_yellow\">\u89e3\u6c7a\u7b56\u3067\u306f\u3042\u308a\u307e\u305b\u3093<\/span>\u3002\u30a8\u30e9\u30fc\u306f\u6d88\u3048\u307e\u3059\u304c\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u4e2d\u8eab\u304c\u8aad\u3081\u306a\u3044\u72b6\u614b\uff08opaque\uff09\u306b\u306a\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u3053\u308c\u306fCORS\u306e\u89e3\u6c7a\u7b56\u3067\u306f\u306a\u3044\nconst res = await fetch(url, { mode: 'no-cors' });\nconsole.log(res.status);   \/\/ \u5e38\u306b 0\u3002\u4e2d\u8eab\u3082\u8aad\u3081\u306a\u3044<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">\u306a\u304a\u3001API\u30ad\u30fc\u3084\u30c8\u30fc\u30af\u30f3\u3092\u30d6\u30e9\u30a6\u30b6\u306eJavaScript\u306b\u66f8\u304f\u3068\u3001\u95b2\u89a7\u8005\u306b\u4e38\u898b\u3048\u306b\u306a\u308a\u307e\u3059\u3002\u8a8d\u8a3c\u304c\u5fc5\u8981\u306aAPI\u306f\u30b5\u30fc\u30d0\u30fc\u5074\u304b\u3089\u547c\u3073\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">\u5b9f\u52d9\u3067\u4f7f\u3048\u308b\u6c4e\u7528\u95a2\u6570<\/h2>\n\n<figure class=\"wp-block-image size-large\" data-dia=\"20099-4\"><img decoding=\"async\" width=\"1568\" height=\"669\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/08\/dia-20099-4.png\" alt=\"\u52d5\u304b\u306a\u3044\u6642\u306e\u539f\u56e0\" class=\"wp-image-20103\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/08\/dia-20099-4.png 1568w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/08\/dia-20099-4-768x328.png 768w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/08\/dia-20099-4-1536x655.png 1536w\" sizes=\"(max-width: 1568px) 100vw, 1568px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">\u3053\u3053\u307e\u3067\u306e\u5185\u5bb9\u3092\u307e\u3068\u3081\u305f\u3001\u305d\u306e\u307e\u307e\u4f7f\u3048\u308b\u95a2\u6570\u3067\u3059\u3002\u30a8\u30e9\u30fc\u51e6\u7406\u30fb\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u30fbJSON\u5224\u5b9a\u3092\u542b\u307f\u307e\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/**\n * fetch\u306e\u30e9\u30c3\u30d1\u30fc\u3002HTTP\u30a8\u30e9\u30fc\u30fb\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3092\u4f8b\u5916\u3068\u3057\u3066\u6271\u3046\u3002\n * @param {string} url\n * @param {object} options fetch\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\n * @param {number} timeout \u30df\u30ea\u79d2\u3002\u65e2\u5b9a8\u79d2\n *\/\nasync function request(url, options = {}, timeout = 8000) {\n  const controller = new AbortController();\n  const timer = setTimeout(() =&gt; controller.abort(), timeout);\n\n  try {\n    const res = await fetch(url, { ...options, signal: controller.signal });\n\n    if (!res.ok) {\n      \/\/ \u30b5\u30fc\u30d0\u30fc\u304c\u30a8\u30e9\u30fc\u8a73\u7d30\u3092\u8fd4\u3059\u5834\u5408\u306b\u5099\u3048\u3066\u672c\u6587\u3082\u8aad\u3080\n      let detail = '';\n      try {\n        detail = await res.text();\n      } catch (_) { \/* \u8aad\u3081\u306a\u304f\u3066\u3082\u7d9a\u884c *\/ }\n      throw new Error(`HTTP ${res.status} ${res.statusText} ${detail.slice(0, 120)}`);\n    }\n\n    \/\/ \u672c\u6587\u304c\u7121\u3044\u5fdc\u7b54\uff08204\u306a\u3069\uff09\u306b\u5099\u3048\u308b\n    if (res.status === 204) return null;\n\n    const type = res.headers.get('content-type') || '';\n    return type.includes('application\/json') ? await res.json() : await res.text();\n  } catch (error) {\n    if (error.name === 'AbortError') throw new Error('\u901a\u4fe1\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3057\u307e\u3057\u305f');\n    throw error;\n  } finally {\n    clearTimeout(timer);\n  }\n}\n\n\/\/ \u4f7f\u3044\u65b9\nconst posts = await request('\/api\/posts');\nconst created = await request('\/api\/posts', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application\/json' },\n  body: JSON.stringify({ title: '\u65b0\u3057\u3044\u8a18\u4e8b' }),\n});<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u95a2\u6570\u30921\u3064\u7528\u610f\u3057\u3066\u304a\u3051\u3070\u3001\u5404\u6240\u3067<code>res.ok<\/code>\u306e\u5224\u5b9a\u3092\u66f8\u304d\u5fd8\u308c\u308b\u4e8b\u6545\u304c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">\u3046\u307e\u304f\u52d5\u304b\u306a\u3044\u3068\u304d\u306e\u78ba\u8a8d\u624b\u9806<\/h2>\n\n<p class=\"wp-block-paragraph\">fetch\u304c\u671f\u5f85\u901a\u308a\u306b\u52d5\u304b\u306a\u3044\u5834\u5408\u3001\u6b21\u306e\u9806\u3067\u78ba\u8a8d\u3059\u308b\u3068\u539f\u56e0\u306b\u305f\u3069\u308a\u7740\u3051\u307e\u3059\u3002<\/p>\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u75c7\u72b6<\/th><th>\u539f\u56e0<\/th><th>\u78ba\u8a8d\u30fb\u5bfe\u51e6<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>catch\u306b\u5165\u3089\u306a\u3044\u306e\u306b\u5931\u6557<\/td><td>HTTP\u30a8\u30e9\u30fc<\/td><td><code>res.ok<\/code>\u3092\u5224\u5b9a\u3059\u308b<\/td><\/tr>\n<tr><td><code>[object Object]<\/code>\u304c\u9001\u3089\u308c\u308b<\/td><td>body\u304c\u6587\u5b57\u5217\u3067\u306a\u3044<\/td><td><code>JSON.stringify<\/code>\u3059\u308b<\/td><\/tr>\n<tr><td>CORS\u30a8\u30e9\u30fc<\/td><td>\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u8a31\u53ef\u306a\u3057<\/td><td>API\u63d0\u4f9b\u5143\u304b\u30d7\u30ed\u30ad\u30b7\u3067\u5bfe\u5fdc<\/td><\/tr>\n<tr><td>await\u3067\u69cb\u6587\u30a8\u30e9\u30fc<\/td><td>async\u95a2\u6570\u306e\u5916<\/td><td>\u95a2\u6570\u306b<code>async<\/code>\u3092\u4ed8\u3051\u308b<\/td><\/tr>\n<tr><td>\u672c\u6587\u304c2\u56de\u8aad\u3081\u306a\u3044<\/td><td>\u65e2\u306b\u6d88\u8cbb\u6e08\u307f<\/td><td><code>res.clone()<\/code>\u3092\u4f7f\u3046<\/td><\/tr>\n<tr><td>\u305a\u3063\u3068\u5f85\u3061\u7d9a\u3051\u308b<\/td><td>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u672a\u8a2d\u5b9a<\/td><td><code>AbortController<\/code>\u3092\u4f7f\u3046<\/td><\/tr>\n<tr><td>\u30c7\u30fc\u30bf\u304cundefined<\/td><td>await\u306e\u4ed8\u3051\u5fd8\u308c<\/td><td><code>.json()<\/code>\u306b\u3082await\u3092\u4ed8\u3051\u308b<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n<p class=\"wp-block-paragraph\">\u6700\u5f8c\u306e\u9805\u76ee\u306f\u521d\u5b66\u8005\u306b\u591a\u3044\u30df\u30b9\u3067\u3059\u3002<code>.json()<\/code>\u81ea\u4f53\u3082Promise\u3092\u8fd4\u3059\u305f\u3081\u3001<span class=\"swl-marker mark_yellow\">await\u30922\u56de\u66f8\u304f<\/span>\u306e\u304c\u6b63\u3057\u3044\u5f62\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">WordPress\u3067\u4f7f\u3046\u5834\u5408\u306e\u6ce8\u610f\u70b9<\/h2>\n\n<p class=\"wp-block-paragraph\">WordPress\u30b5\u30a4\u30c8\u3067fetch\u3092\u4f7f\u3046\u3068\u304d\u306f\u3001REST API\u3068\u8a8d\u8a3c\u307e\u308f\u308a\u306b\u56fa\u6709\u306e\u4f5c\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">REST API\u304b\u3089\u8a18\u4e8b\u3092\u53d6\u5f97\u3059\u308b<\/h3>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u516c\u958b\u8a18\u4e8b\u306e\u53d6\u5f97\u306f\u8a8d\u8a3c\u4e0d\u8981\nconst res = await fetch('\/wp-json\/wp\/v2\/posts?per_page=5&amp;_fields=id,title,link');\nconst posts = await res.json();\n\ndocument.querySelector('#latest').innerHTML = posts\n  .map(p =&gt; `&lt;li&gt;&lt;a href=\"${p.link}\"&gt;${p.title.rendered}&lt;\/a&gt;&lt;\/li&gt;`)\n  .join('');<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>_fields<\/code>\u3067\u5fc5\u8981\u306a\u9805\u76ee\u3060\u3051\u6307\u5b9a\u3059\u308b\u3068\u3001<span class=\"swl-marker mark_yellow\">\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u6570\u5206\u306e\u4e00\u306b\u8efd\u304f\u306a\u308a\u307e\u3059<\/span>\u3002\u8a18\u4e8b\u672c\u6587\u307e\u3067\u542b\u3081\u308b\u30681\u4ef6\u3067\u6570\u5341KB\u306b\u306a\u308b\u305f\u3081\u3001\u4e00\u89a7\u8868\u793a\u3067\u306f\u5fc5\u305a\u7d5e\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">\u66f4\u65b0\u7cfb\u306fnonce\u304c\u5fc5\u8981<\/h3>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>\/\/ \u6295\u7a3f\u306e\u66f4\u65b0\u306a\u3069\u3001\u66f8\u304d\u8fbc\u307f\u7cfb\u306fnonce\u3092\u6dfb\u3048\u308b\nconst res = await fetch('\/wp-json\/wp\/v2\/posts\/123', {\n  method: 'POST',\n  headers: {\n    'Content-Type': 'application\/json',\n    'X-WP-Nonce': window.wpApiSettings.nonce,   \/\/ wp_localize_script\u3067\u6e21\u3059\n  },\n  credentials: 'same-origin',   \/\/ \u30ed\u30b0\u30a4\u30f3Cookie\u3092\u9001\u308b\n  body: JSON.stringify({ title: '\u65b0\u3057\u3044\u30bf\u30a4\u30c8\u30eb' }),\n});<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>credentials: 'same-origin'<\/code>\u3092\u5fd8\u308c\u308b\u3068\u30ed\u30b0\u30a4\u30f3\u72b6\u614b\u304c\u4f1d\u308f\u3089\u305a\u3001401\u304c\u8fd4\u308a\u307e\u3059\u3002nonce\u306f\u6709\u52b9\u671f\u9650\u304c\u77ed\u3044\u305f\u3081\u3001\u9577\u6642\u9593\u958b\u3044\u305f\u307e\u307e\u306e\u753b\u9762\u3067\u306f\u518d\u53d6\u5f97\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>&lt;?php\n\/\/ functions.php \u5074\u3067nonce\u3092JS\u306b\u6e21\u3059\nadd_action( 'wp_enqueue_scripts', function () {\n\twp_enqueue_script( 'my-app', get_stylesheet_directory_uri() . '\/app.js', [], null, true );\n\twp_localize_script( 'my-app', 'wpApiSettings', [\n\t\t'root'  =&gt; esc_url_raw( rest_url() ),\n\t\t'nonce' =&gt; wp_create_nonce( 'wp_rest' ),\n\t] );\n} );<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\">\u3053\u306e3\u884c\u3092\u66f8\u3044\u3066\u304a\u3051\u3070\u3001JavaScript\u5074\u304b\u3089\u5b89\u5168\u306bREST API\u3092\u547c\u3079\u307e\u3059\u3002API\u30ad\u30fc\u306e\u3088\u3046\u306b\u30bd\u30fc\u30b9\u3078\u76f4\u66f8\u304d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n<h2 class=\"wp-block-heading\">\u8868\u793a\u901f\u5ea6\u3078\u306e\u914d\u616e<\/h2>\n\n<p class=\"wp-block-paragraph\">fetch\u306f\u30da\u30fc\u30b8\u8868\u793a\u5f8c\u306b\u8d70\u308b\u305f\u3081\u3001\u66f8\u304d\u65b9\u306b\u3088\u3063\u3066\u306f\u8aad\u8005\u3092\u5f85\u305f\u305b\u307e\u3059\u30023\u70b9\u3060\u3051\u610f\u8b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8aad\u307f\u8fbc\u307f\u4e2d\u306e\u8868\u793a\u3092\u51fa\u3059<\/strong>\uff1a\u7a7a\u767d\u306e\u307e\u307e\u5f85\u305f\u305b\u306a\u3044\u3002\u30c6\u30ad\u30b9\u30c81\u884c\u3067\u3082\u52b9\u679c\u304c\u3042\u308b<\/li>\n<li><strong>\u5931\u6557\u6642\u306e\u6587\u8a00\u3092\u7528\u610f\u3059\u308b<\/strong>\uff1a\u4f55\u3082\u51fa\u306a\u3044\u3068\u58ca\u308c\u305f\u3068\u601d\u308f\u308c\u308b<\/li>\n<li><strong>\u9ad8\u3055\u3092\u5148\u306b\u78ba\u4fdd\u3059\u308b<\/strong>\uff1a\u5f8c\u304b\u3089\u5dee\u3057\u8fbc\u3080\u3068\u753b\u9762\u304c\u98db\u3073\u3001CLS\u304c\u60aa\u5316\u3059\u308b<\/li>\n<\/ul>\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>const list = document.querySelector('#post-list');\n\n\/\/ \u9ad8\u3055\u3092\u4fdd\u3063\u305f\u72b6\u614b\u3067\u8aad\u307f\u8fbc\u307f\u4e2d\u3092\u8868\u793a\u3059\u308b\nlist.style.minHeight = '240px';\nlist.innerHTML = '&lt;li class=\"loading\"&gt;\u8aad\u307f\u8fbc\u307f\u4e2d\u2026&lt;\/li&gt;';\n\ntry {\n  const posts = await request('\/wp-json\/wp\/v2\/posts?per_page=5');\n  list.innerHTML = posts.map(p =&gt; `&lt;li&gt;${p.title.rendered}&lt;\/li&gt;`).join('');\n} catch (e) {\n  list.innerHTML = '&lt;li class=\"error\"&gt;\u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u518d\u8aad\u307f\u8fbc\u307f\u3057\u3066\u304f\u3060\u3055\u3044\u3002&lt;\/li&gt;';\n} finally {\n  list.style.minHeight = '';\n}<\/code><\/pre><\/div>\n\n<p class=\"wp-block-paragraph\"><code>min-height<\/code>\u3067\u5148\u306b\u5834\u6240\u3092\u53d6\u3063\u3066\u304a\u304f\u3068\u3001<span class=\"swl-marker mark_yellow\">\u30c7\u30fc\u30bf\u304c\u5c4a\u3044\u305f\u77ac\u9593\u306b\u4e0b\u306e\u8981\u7d20\u304c\u62bc\u3057\u4e0b\u3052\u3089\u308c\u308b\u73fe\u8c61<\/span>\u3092\u9632\u3052\u307e\u3059\u3002Core Web Vitals\u306eCLS\u306b\u76f4\u7d50\u3059\u308b\u914d\u616e\u3067\u3059\u3002<\/p>\n\n<figure class=\"wp-block-table\"><table>\n<thead><tr><th>\u5bfe\u7b56<\/th><th>\u52b9\u679c<\/th><th>\u624b\u9593<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u8aad\u307f\u8fbc\u307f\u4e2d\u306e\u8868\u793a<\/td><td>\u96e2\u8131\u3092\u6e1b\u3089\u3059<\/td><td>1\u884c<\/td><\/tr>\n<tr><td>\u30a8\u30e9\u30fc\u6587\u8a00<\/td><td>\u4e0d\u4fe1\u611f\u3092\u9632\u3050<\/td><td>1\u884c<\/td><\/tr>\n<tr><td>min-height\u3067\u9ad8\u3055\u78ba\u4fdd<\/td><td>CLS\u3092\u9632\u3050<\/td><td>2\u884c<\/td><\/tr>\n<tr><td>_fields\u3067\u9805\u76ee\u3092\u7d5e\u308b<\/td><td>\u901a\u4fe1\u91cf\u3092\u524a\u6e1b<\/td><td>URL\u306b\u8ffd\u8a18<\/td><\/tr>\n<\/tbody>\n<\/table><\/figure>\n\n<p class=\"wp-block-paragraph\">\u3069\u308c\u3082\u6570\u884c\u3067\u6e08\u307f\u307e\u3059\u304c\u3001\u4f53\u611f\u901f\u5ea6\u3068\u4fe1\u983c\u611f\u306b\u52b9\u304d\u307e\u3059\u3002fetch\u3092\u66f8\u3044\u305f\u3089\u30bb\u30c3\u30c8\u3067\u5165\u308c\u308b\u7fd2\u6163\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n<p class=\"wp-block-paragraph\">fetch\u306f\u300c\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u308b\u300d\u300cResponse\u3092\u53d7\u3051\u53d6\u308b\u300d\u300c\u672c\u6587\u3092\u53d6\u308a\u51fa\u3059\u300d\u306e3\u6bb5\u968e\u3067\u52d5\u304d\u307e\u3059\u3002async\/await\u3067\u66f8\u3051\u3070\u4e0a\u304b\u3089\u9806\u306b\u8aad\u3081\u308b\u30b3\u30fc\u30c9\u306b\u306a\u308a\u3001\u5b9f\u52d9\u3067\u306f\u3053\u3061\u3089\u304c\u4e3b\u6d41\u3067\u3059\u3002\u6700\u5927\u306e\u6ce8\u610f\u70b9\u306f404\u3084500\u3067\u306fcatch\u306b\u5165\u3089\u306a\u3044\u3053\u3068\u3067\u3001\u5fc5\u305a<code>res.ok<\/code>\u3067\u5224\u5b9a\u3057\u3066\u81ea\u5206\u3067\u4f8b\u5916\u3092\u6295\u3052\u307e\u3059\u3002POST\u3067\u306f<code>body<\/code>\u3092<code>JSON.stringify<\/code>\u3067\u6587\u5b57\u5217\u306b\u3057\u3001FormData\u3092\u4f7f\u3046\u5834\u5408\u306f<code>Content-Type<\/code>\u3092\u81ea\u5206\u3067\u6307\u5b9a\u3057\u306a\u3044\u3053\u3068\u3002\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306f\u6a19\u6e96\u306b\u306a\u3044\u305f\u3081<code>AbortController<\/code>\u3067\u5b9f\u88c5\u3057\u3001\u8907\u6570\u53d6\u5f97\u306f<code>Promise.all<\/code>\u3067\u4e26\u5217\u5316\u3057\u307e\u3059\u3002CORS\u30a8\u30e9\u30fc\u306f\u30b5\u30fc\u30d0\u30fc\u5074\u306e\u8a2d\u5b9a\u554f\u984c\u3067\u3001<code>mode: 'no-cors'<\/code>\u3067\u306f\u89e3\u6c7a\u3057\u307e\u305b\u3093\u3002<\/p>\n\n<!-- withmedia-faq -->\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u8cea\u554f\uff08FAQ\uff09<\/h2>\n\n<h3 class=\"wp-block-heading\">fetch\u3067404\u304c\u8fd4\u3063\u3066\u3082catch\u306b\u5165\u3089\u306a\u3044\u306e\u306f\u306a\u305c\u3067\u3059\u304b\uff1f<\/h3>\n\n<p class=\"wp-block-paragraph\">fetch\u306f\u901a\u4fe1\u304c\u6210\u7acb\u3057\u305f\u6642\u70b9\u3067\u6210\u529f\u3068\u307f\u306a\u3059\u4ed5\u69d8\u306e\u305f\u3081\u3067\u3059\u3002404\u3084500\u306f\u30b5\u30fc\u30d0\u30fc\u304c\u6b63\u5e38\u306b\u5fdc\u7b54\u3057\u305f\u7d50\u679c\u306a\u306e\u3067\u3001Promise\u306f\u89e3\u6c7a\u3055\u308c\u307e\u3059\u3002catch\u306b\u5165\u308b\u306e\u306f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u65ad\u30fbCORS\u9055\u53cd\u30fbURL\u304c\u4e0d\u6b63\u306a\u5834\u5408\u3060\u3051\u3067\u3059\u3002<code>if (!res.ok) throw new Error(...)<\/code>\u3092\u5fc5\u305a\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">await\u306f\u3069\u3053\u306b\u66f8\u3051\u3070\u3044\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n<p class=\"wp-block-paragraph\"><code>async<\/code>\u3092\u4ed8\u3051\u305f\u95a2\u6570\u306e\u4e2d\u3067\u306e\u307f\u4f7f\u3048\u307e\u3059\u3002<code>fetch()<\/code>\u3068\u3001\u672c\u6587\u3092\u53d6\u308a\u51fa\u3059<code>.json()<\/code>\u306e\u4e21\u65b9\u304cPromise\u3092\u8fd4\u3059\u305f\u3081\u3001await\u306f2\u56de\u5fc5\u8981\u3067\u3059\u3002\u4ed8\u3051\u5fd8\u308c\u308b\u3068\u3001\u30c7\u30fc\u30bf\u3067\u306f\u306a\u304fPromise\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5909\u6570\u306b\u5165\u308a\u3001undefined\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u539f\u56e0\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">POST\u3067\u30c7\u30fc\u30bf\u304c\u5c4a\u304d\u307e\u305b\u3093\u3002<\/h3>\n\n<p class=\"wp-block-paragraph\"><code>body<\/code>\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u305d\u306e\u307e\u307e\u6e21\u3057\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<code>JSON.stringify()<\/code>\u3067\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u3001<code>Content-Type: application\/json<\/code>\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u9006\u306bFormData\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001Content-Type\u3092\u624b\u3067\u66f8\u304f\u3068\u58ca\u308c\u308b\u305f\u3081\u6307\u5b9a\u3057\u307e\u305b\u3093\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">CORS\u30a8\u30e9\u30fc\u306fJavaScript\u5074\u3067\u89e3\u6c7a\u3067\u304d\u307e\u3059\u304b\uff1f<\/h3>\n\n<p class=\"wp-block-paragraph\">\u3067\u304d\u307e\u305b\u3093\u3002\u30d6\u30e9\u30a6\u30b6\u304c\u30a2\u30af\u30bb\u30b9\u5143\u3092\u5236\u9650\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3001\u8a31\u53ef\u3092\u51fa\u305b\u308b\u306e\u306fAPI\u63d0\u4f9b\u5074\u306e\u30b5\u30fc\u30d0\u30fc\u3060\u3051\u3067\u3059\u3002\u81ea\u793eAPI\u306a\u3089<code>Access-Control-Allow-Origin<\/code>\u3092\u8a2d\u5b9a\u3057\u3001\u5916\u90e8API\u306a\u3089\u81ea\u5206\u306e\u30b5\u30fc\u30d0\u30fc\u3092\u7d4c\u7531\u3055\u305b\u307e\u3059\u3002<code>mode: 'no-cors'<\/code>\u306f\u30a8\u30e9\u30fc\u3092\u6d88\u3059\u3060\u3051\u3067\u3001\u5fdc\u7b54\u306e\u4e2d\u8eab\u306f\u8aad\u3081\u307e\u305b\u3093\u3002<\/p>\n\n<h3 class=\"wp-block-heading\">axios\u306a\u3069\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3079\u304d\u3067\u3059\u304b\uff1f<\/h3>\n\n<p class=\"wp-block-paragraph\">fetch\u3067\u5341\u5206\u306a\u30b1\u30fc\u30b9\u304c\u307b\u3068\u3093\u3069\u3067\u3059\u3002\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3084\u30a8\u30e9\u30fc\u51e6\u7406\u304c\u6700\u521d\u304b\u3089\u5099\u308f\u3063\u3066\u3044\u308b\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u306e\u6c4e\u7528\u95a2\u6570\u306e\u3088\u3046\u306a\u30e9\u30c3\u30d1\u30fc\u30921\u3064\u4f5c\u308c\u3070\u540c\u7b49\u306e\u4f7f\u3044\u52dd\u624b\u306b\u306a\u308a\u307e\u3059\u3002\u8aad\u307f\u8fbc\u3080\u30d5\u30a1\u30a4\u30eb\u3092\u5897\u3084\u3055\u305a\u306b\u6e08\u3080\u3076\u3093\u3001\u8868\u793a\u901f\u5ea6\u306e\u9762\u3067\u3082\u6709\u5229\u3067\u3059\u3002<\/p>\n\n<!-- \/withmedia-faq -->\n\n\n<!-- withmedia-related -->\n<h2 class=\"wp-block-heading\">\u3042\u308f\u305b\u3066\u8aad\u307f\u305f\u3044\u95a2\u9023\u8a18\u4e8b<\/h2>\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/withcode.tech\/media\/javascript-dom-manipulation-guide\/\">JavaScript\u306eDOM\u64cd\u4f5c\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u8981\u7d20\u306e\u53d6\u5f97\u30fb\u5909\u66f4\u30fb\u8ffd\u52a0<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/javascript-not-working\/\">JavaScript\u304c\u52d5\u304b\u306a\u3044\u539f\u56e0\u3068\u5bfe\u51e6\u6cd5\uff5c\u30a8\u30e9\u30fc\u306e\u8aad\u307f\u65b9<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/javascript-stop-reason\/\">JavaScript\u304c\u6709\u52b9\u306a\u306e\u306b\u52d5\u304b\u306a\u3044\u539f\u56e0\u3068\u89e3\u6c7a\u6cd5\u3010\u5b8c\u5168\u30ac\u30a4\u30c9\u3011<\/a><\/li>\n<\/ul>\n\n<h2 class=\"wp-block-heading\">AI\u30b9\u30ad\u30eb\u3067\u3001\u672a\u6765\u306e\u81ea\u5206\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\uff01<\/h2>\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/s.lmes.jp\/landing-qr\/2010578884-C5To3Fmv?uLand=phzKXf\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" width=\"1254\" height=\"1254\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner.jpg\" alt=\"\u4eca\u306a\u3089\u5b8c\u5168\u7121\u6599\u3067AI\u3092\u5b66\u3079\u308b\uff01WithAI\" class=\"wp-image-18841\" style=\"max-width:600px;width:100%;height:auto\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner.jpg 1254w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner-768x768.jpg 768w\" sizes=\"(max-width: 1254px) 100vw, 1254px\" \/><\/a><\/figure>\n\n<h3 class=\"wp-block-heading\">\u4eca\u306a\u3089\u5b8c\u5168\u7121\u6599\u3067AI\u3092\u5b66\u3079\u308b\uff01<\/h3>\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52d5\u753b\u3084\u5b9f\u8df5\u3067\u697d\u3057\u304f\u5b66\u3079\u308b<\/strong>\uff1a\u521d\u5fc3\u8005\u3067\u3082\u5b89\u5fc3\u306e\u30ab\u30ea\u30ad\u30e5\u30e9\u30e0<\/li>\n<li><strong>\u30b9\u30de\u30db\u30fbPC\u3069\u3061\u3089\u3067\u3082OK<\/strong>\uff1a\u597d\u304d\u306a\u6642\u9593\u306b\u5b66\u7fd2\u3067\u304d\u308b<\/li>\n<li><strong>\u6599\u91d1\u306f\u4e00\u5207\u30ca\u30b7<\/strong>\uff1a<span class=\"swl-marker mark_yellow\">0\u5186\u3067AI\u30b9\u30ad\u30eb\u304c\u8eab\u306b\u3064\u304f<\/span><\/li>\n<\/ul>\n\n<p>\u76ee\u7684\u306b\u5408\u308f\u305b\u3066\u9078\u3079\u308b\u300cAI\u526f\u696d\u300d\u300cAI\u8ee2\u8077\u300d\u300cAI\u6d3b\u7528\u300d\u306e3\u30b3\u30fc\u30b9\u3092\u7528\u610f\u3002\u526f\u53ce\u5165\u30fb\u30ad\u30e3\u30ea\u30a2\u30c1\u30a7\u30f3\u30b8\u30fb\u65e5\u5e38\u306e\u751f\u7523\u6027\u30a2\u30c3\u30d7\u307e\u3067\u3001\u3042\u306a\u305f\u306e\u30b4\u30fc\u30eb\u306b\u5408\u308f\u305b\u3066AI\u3092\u5b66\u3079\u307e\u3059\u3002<\/p>\n\n<p>\u4f1a\u54e1\u767b\u9332\u306f\u30ab\u30f3\u30bf\u30f330\u79d2\u3067\u5b8c\u4e86\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u516c\u5f0fLINE\u304b\u3089\u3001\u7121\u6599\u3067AI\u5b66\u7fd2\u3092\u30b9\u30bf\u30fc\u30c8\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n\n<div class=\"wp-block-buttons\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/s.lmes.jp\/landing-qr\/2010578884-C5To3Fmv?uLand=phzKXf\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"background-color:#06c755\"><strong>\u516c\u5f0fLINE\u304b\u3089\u5b66\u7fd2\u3092\u30b9\u30bf\u30fc\u30c8<\/strong><\/a><\/div><\/div>\n\n\n<!-- withmedia-faq-schema -->\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"fetch\u3067404\u304c\u8fd4\u3063\u3066\u3082catch\u306b\u5165\u3089\u306a\u3044\u306e\u306f\u306a\u305c\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"fetch\u306f\u901a\u4fe1\u304c\u6210\u7acb\u3057\u305f\u6642\u70b9\u3067\u6210\u529f\u3068\u307f\u306a\u3059\u4ed5\u69d8\u306e\u305f\u3081\u3067\u3059\u3002404\u3084500\u306f\u30b5\u30fc\u30d0\u30fc\u304c\u6b63\u5e38\u306b\u5fdc\u7b54\u3057\u305f\u7d50\u679c\u306a\u306e\u3067\u3001Promise\u306f\u89e3\u6c7a\u3055\u308c\u307e\u3059\u3002catch\u306b\u5165\u308b\u306e\u306f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u65ad\u30fbCORS\u9055\u53cd\u30fbURL\u304c\u4e0d\u6b63\u306a\u5834\u5408\u3060\u3051\u3067\u3059\u3002if (!res.ok) throw new Error(...)\u3092\u5fc5\u305a\u66f8\u3044\u3066\u304f\u3060\u3055\u3044\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"await\u306f\u3069\u3053\u306b\u66f8\u3051\u3070\u3044\u3044\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"async\u3092\u4ed8\u3051\u305f\u95a2\u6570\u306e\u4e2d\u3067\u306e\u307f\u4f7f\u3048\u307e\u3059\u3002fetch()\u3068\u3001\u672c\u6587\u3092\u53d6\u308a\u51fa\u3059.json()\u306e\u4e21\u65b9\u304cPromise\u3092\u8fd4\u3059\u305f\u3081\u3001await\u306f2\u56de\u5fc5\u8981\u3067\u3059\u3002\u4ed8\u3051\u5fd8\u308c\u308b\u3068\u3001\u30c7\u30fc\u30bf\u3067\u306f\u306a\u304fPromise\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5909\u6570\u306b\u5165\u308a\u3001undefined\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u539f\u56e0\u306b\u306a\u308a\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"POST\u3067\u30c7\u30fc\u30bf\u304c\u5c4a\u304d\u307e\u305b\u3093\u3002\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"body\u306b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u305d\u306e\u307e\u307e\u6e21\u3057\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002JSON.stringify()\u3067\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u3001Content-Type: application\/json\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u9006\u306bFormData\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001Content-Type\u3092\u624b\u3067\u66f8\u304f\u3068\u58ca\u308c\u308b\u305f\u3081\u6307\u5b9a\u3057\u307e\u305b\u3093\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"CORS\u30a8\u30e9\u30fc\u306fJavaScript\u5074\u3067\u89e3\u6c7a\u3067\u304d\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u3067\u304d\u307e\u305b\u3093\u3002\u30d6\u30e9\u30a6\u30b6\u304c\u30a2\u30af\u30bb\u30b9\u5143\u3092\u5236\u9650\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3001\u8a31\u53ef\u3092\u51fa\u305b\u308b\u306e\u306fAPI\u63d0\u4f9b\u5074\u306e\u30b5\u30fc\u30d0\u30fc\u3060\u3051\u3067\u3059\u3002\u81ea\u793eAPI\u306a\u3089Access-Control-Allow-Origin\u3092\u8a2d\u5b9a\u3057\u3001\u5916\u90e8API\u306a\u3089\u81ea\u5206\u306e\u30b5\u30fc\u30d0\u30fc\u3092\u7d4c\u7531\u3055\u305b\u307e\u3059\u3002mode: 'no-cors'\u306f\u30a8\u30e9\u30fc\u3092\u6d88\u3059\u3060\u3051\u3067\u3001\u5fdc\u7b54\u306e\u4e2d\u8eab\u306f\u8aad\u3081\u307e\u305b\u3093\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"axios\u306a\u3069\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3079\u304d\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"fetch\u3067\u5341\u5206\u306a\u30b1\u30fc\u30b9\u304c\u307b\u3068\u3093\u3069\u3067\u3059\u3002\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3084\u30a8\u30e9\u30fc\u51e6\u7406\u304c\u6700\u521d\u304b\u3089\u5099\u308f\u3063\u3066\u3044\u308b\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u306e\u6c4e\u7528\u95a2\u6570\u306e\u3088\u3046\u306a\u30e9\u30c3\u30d1\u30fc\u30921\u3064\u4f5c\u308c\u3070\u540c\u7b49\u306e\u4f7f\u3044\u52dd\u624b\u306b\u306a\u308a\u307e\u3059\u3002\u8aad\u307f\u8fbc\u3080\u30d5\u30a1\u30a4\u30eb\u3092\u5897\u3084\u3055\u305a\u306b\u6e08\u3080\u3076\u3093\u3001\u8868\u793a\u901f\u5ea6\u306e\u9762\u3067\u3082\u6709\u5229\u3067\u3059\u3002\"\n      }\n    }\n  ]\n}\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>\u751f\u5f92 API\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u3063\u3066\u304d\u3066\u753b\u9762\u306b\u51fa\u3057\u305f\u3044\u3093\u3067\u3059\u304c\u3001fetch\u306e\u66f8\u304d\u65b9\u304c\u3044\u307e\u3044\u3061\u63b4\u3081\u307e\u305b\u3093\u2026\u3002 \u30da\u30f3\u535a\u58eb fetch\u306f\u300c\u6295\u3052\u308b\u30fb\u5f85\u3064\u30fb\u53d7\u3051\u53d6\u308b\u300d\u306e3\u6bb5\u968e\u3067\u8003\u3048\u308b\u3068\u7c21\u5358\u3060\u3088\u3002async\/await\u3067\u66f8\u3051\u3070\u898b\u305f\u76ee\u3082\u307b\u307c [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":20447,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"swell_btn_cv_data":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":""},"categories":[34],"tags":[],"class_list":["post-20099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/20099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/comments?post=20099"}],"version-history":[{"count":3,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/20099\/revisions"}],"predecessor-version":[{"id":20472,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/20099\/revisions\/20472"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/media\/20447"}],"wp:attachment":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/media?parent=20099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/categories?post=20099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/tags?post=20099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}