-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4c615799.61f17277.js
1 lines (1 loc) · 24.7 KB
/
4c615799.61f17277.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[33],{173:function(e,t,a){"use strict";a.d(t,"a",(function(){return s})),a.d(t,"b",(function(){return u}));var n=a(0),r=a.n(n);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function b(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function c(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?b(Object(a),!0).forEach((function(t){l(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):b(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function i(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var o=r.a.createContext({}),p=function(e){var t=r.a.useContext(o),a=t;return e&&(a="function"==typeof e?e(t):c(c({},t),e)),a},s=function(e){var t=p(e.components);return r.a.createElement(o.Provider,{value:t},e.children)},j={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},O=r.a.forwardRef((function(e,t){var a=e.components,n=e.mdxType,l=e.originalType,b=e.parentName,o=i(e,["components","mdxType","originalType","parentName"]),s=p(a),O=n,u=s["".concat(b,".").concat(O)]||s[O]||j[O]||l;return a?r.a.createElement(u,c(c({ref:t},o),{},{components:a})):r.a.createElement(u,c({ref:t},o))}));function u(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var l=a.length,b=new Array(l);b[0]=O;var c={};for(var i in t)hasOwnProperty.call(t,i)&&(c[i]=t[i]);c.originalType=e,c.mdxType="string"==typeof e?e:n,b[1]=c;for(var o=2;o<l;o++)b[o]=a[o];return r.a.createElement.apply(null,b)}return r.a.createElement.apply(null,a)}O.displayName="MDXCreateElement"},174:function(e,t,a){"use strict";a.r(t),t.default=a.p+"assets/images/patreon-15b4e66595efdb2e079faf18b89cff7c.png"},90:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return b})),a.d(t,"metadata",(function(){return c})),a.d(t,"rightToc",(function(){return i})),a.d(t,"default",(function(){return p}));var n=a(2),r=a(6),l=(a(0),a(173)),b={id:"javascript28",title:"Fetch API",sidebar_label:"Fetch API"},c={unversionedId:"javascript28",id:"javascript28",isDocsHomePage:!1,title:"Fetch API",description:"Fetch API \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 JavaScript \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0443 XMLHttpRequest. \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c fetch(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise.",source:"@site/docs/javascript28.md",slug:"/javascript28",permalink:"/docs/javascript28",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/javascript28.md",version:"current",sidebar_label:"Fetch API",sidebar:"someSidebar",previous:{title:"\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e",permalink:"/docs/javascript25"},next:{title:"\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432",permalink:"/docs/javascript30"}},i=[{value:"\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441",id:"\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441",children:[]},{value:"\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430",id:"\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b-\u0437\u0430\u043f\u0440\u043e\u0441\u0430",children:[]},{value:"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430",id:"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435-\u043e\u0442\u0432\u0435\u0442\u0430",children:[]},{value:"\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430",id:"\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430-\u043e\u0442\u0432\u0435\u0442\u0430",children:[]},{value:"\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a",id:"\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430-\u043e\u0448\u0438\u0431\u043e\u043a",children:[]},{value:"\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432",id:"\u043f\u0440\u0438\u043c\u0435\u0440\u044b-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432",children:[]},{value:"\u0412\u043e\u043f\u0440\u043e\u0441\u044b",id:"\u0432\u043e\u043f\u0440\u043e\u0441\u044b",children:[]},{value:"\u0421\u0441\u044b\u043b\u043a\u0438",id:"\u0441\u0441\u044b\u043b\u043a\u0438",children:[]},{value:"Contributors \u2728",id:"contributors-",children:[]}],o={rightToc:i};function p(e){var t=e.components,b=Object(r.a)(e,["components"]);return Object(l.b)("wrapper",Object(n.a)({},o,b,{components:t,mdxType:"MDXLayout"}),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"Fetch API")," \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 JavaScript \u043e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0443 ",Object(l.b)("inlineCode",{parentName:"p"},"XMLHttpRequest"),". \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c ",Object(l.b)("inlineCode",{parentName:"p"},"fetch()"),", \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 ",Object(l.b)("a",Object(n.a)({parentName:"p"},{href:"https://react-native-village.github.io/docs/javascript24"}),"Promise"),"."),Object(l.b)("h2",{id:"\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441"},"\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441"),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"let promise = fetch(url, [options])\n")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"url")," - URL \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430;"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"options")," - \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430.")),Object(l.b)("p",null,"\u0417\u0430\u0434\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 ",Object(l.b)("inlineCode",{parentName:"p"},"fetch()")," \u0431\u0435\u0437 ",Object(l.b)("inlineCode",{parentName:"p"},"options")," \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 GET-\u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 ",Object(l.b)("inlineCode",{parentName:"p"},"URL"),"."),Object(l.b)("h2",{id:"\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b-\u0437\u0430\u043f\u0440\u043e\u0441\u0430"},"\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430"),Object(l.b)("ol",null,Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"method")," - \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (GET, POST, PUT, DELETE, HEAD);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"headers")," - HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"body")," - \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 method: POST / PUT);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"cache")," - \u0440\u0435\u0436\u0438\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (default, reload, no-cache);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"mode")," - \u0440\u0435\u0436\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (cors, no-cors, same-origin);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"redirect")," - \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f(follow, error, manual);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"referrer")," - \u0440\u0435\u0444\u0435\u0440\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"signal")," - AbortSignal, \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"credentials")," - \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 cookies \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c - mit, same-origin.")),Object(l.b)("p",null,"\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438"),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"fetch('https://example.com/', {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json'\n }\n}\n")),Object(l.b)("h2",{id:"\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435-\u043e\u0442\u0432\u0435\u0442\u0430"},"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430"),Object(l.b)("p",null,"\u041c\u0435\u0442\u043e\u0434 ",Object(l.b)("inlineCode",{parentName:"p"},"fetch()")," \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 ",Object(l.b)("a",Object(n.a)({parentName:"p"},{href:"https://react-native-village.github.io/docs/javascript24"}),"Promise")," \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 ",Object(l.b)("inlineCode",{parentName:"p"},"Response"),", \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:"),Object(l.b)("ol",null,Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"status")," - \u043a\u043e\u0434 \u043e\u0442\u0432\u0435\u0442\u0430;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"statusText")," - \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043a\u043e\u0434\u0443 \u043e\u0442\u0432\u0435\u0442\u0430;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"ok")," - \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 (true: 200-299);"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"headers")," - \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u043e\u0442\u0432\u0435\u0442\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043b\u044e\u0447 - \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 - \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043b\u044e\u0447\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"url")," - URL, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"body")," - \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ",Object(l.b)("inlineCode",{parentName:"li"},"ReadableStream")),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"bodyUsed")," - \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.")),Object(l.b)("h2",{id:"\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430-\u043e\u0442\u0432\u0435\u0442\u0430"},"\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430"),Object(l.b)("p",null,"\u041f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ",Object(l.b)("inlineCode",{parentName:"p"},"ReadableStream"),". \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:"),Object(l.b)("ol",null,Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"text()")," - \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"json()")," - \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"blob()")," - \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 Blob;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"formData()")," - \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442 \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 FormData;"),Object(l.b)("li",{parentName:"ol"},Object(l.b)("inlineCode",{parentName:"li"},"arrayBuffer()")," - \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 ArrayBuffer.")),Object(l.b)("p",null,"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 JSON."),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"let res = await fetch('https://example.com/') // \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\nlet com = await res.json(); // \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442\n")),Object(l.b)("h2",{id:"\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430-\u043e\u0448\u0438\u0431\u043e\u043a"},"\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a"),Object(l.b)("p",null,"\u0423\u0437\u043d\u0430\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u043b\u0438 ",Object(l.b)("inlineCode",{parentName:"p"},"fetch()"),' \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432: "status" \u0438 "ok". \u041f\u0440\u0438\u043c\u0435\u0440:'),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"let res = await fetch('https://example.com/') // \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\n\nif (res.ok) { // \u0415\u0441\u043b\u0438 HTTP-\u0441\u0442\u0430\u0442\u0443\u0441 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 200-299\n let answer = await res.text() // \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442\n} else {\n alert('\u041e\u0448\u0438\u0431\u043a\u0430: ' + res.status) // \u0418\u043d\u0430\u0447\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u0434 \u043e\u0442\u0432\u0435\u0442\u0430\n}\n")),Object(l.b)("h2",{id:"\u043f\u0440\u0438\u043c\u0435\u0440\u044b-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432"},"\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432"),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"fetch('https://example.com/api/data', {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json'\n }\n }).then(response => {\n console.log(response.bodyUsed); // false\n let result = await response.json();\n console.log(response.bodyUsed); // true\n return result;\n });\n")),Object(l.b)("p",null,"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 POST "),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"let response = await fetch('/article/fetch/post/user', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json;charset=utf-8'\n },\n body: JSON.stringify(user)\n});\n\nlet result = await response.json();\nalert(result.message);\n")),Object(l.b)("p",null,"\u0411\u0435\u0437 ",Object(l.b)("inlineCode",{parentName:"p"},"await")),Object(l.b)("pre",null,Object(l.b)("code",Object(n.a)({parentName:"pre"},{className:"language-jsx"}),"fetch('https://api.github.com/users/KrunalLathiya')\n.then(res => res.json())\n.then(json => console.log(json));\n")),Object(l.b)("h2",{id:"\u0432\u043e\u043f\u0440\u043e\u0441\u044b"},"\u0412\u043e\u043f\u0440\u043e\u0441\u044b"),Object(l.b)("ol",null,Object(l.b)("li",{parentName:"ol"},"\u0427\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 ",Object(l.b)("inlineCode",{parentName:"li"},"fetch()"),"?")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u0424\u0443\u043d\u043a\u0446\u0438\u044e;"),Object(l.b)("li",{parentName:"ul"},"\u041e\u0431\u044a\u0435\u043a\u0442;"),Object(l.b)("li",{parentName:"ul"},"\u041f\u0440\u043e\u043c\u0438\u0441\u044b.")),Object(l.b)("ol",{start:2},Object(l.b)("li",{parentName:"ol"},"\u0417\u0430\u0434\u0430\u0432 \u0432 ",Object(l.b)("inlineCode",{parentName:"li"},"fetch()")," \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 URL, \u043a\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c?")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"POST;"),Object(l.b)("li",{parentName:"ul"},"GET;"),Object(l.b)("li",{parentName:"ul"},"PUT.")),Object(l.b)("ol",{start:3},Object(l.b)("li",{parentName:"ol"},"\u041a\u0430\u043a\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438?")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"redirect;"),Object(l.b)("li",{parentName:"ul"},"headers;"),Object(l.b)("li",{parentName:"ul"},"credentials.")),Object(l.b)("ol",{start:4},Object(l.b)("li",{parentName:"ol"},"\u041a\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443?")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"blob();"),Object(l.b)("li",{parentName:"ul"},"json();"),Object(l.b)("li",{parentName:"ul"},"text().")),Object(l.b)("ol",{start:5},Object(l.b)("li",{parentName:"ol"},"\u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e ",Object(l.b)("inlineCode",{parentName:"li"},"ok")," \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 ",Object(l.b)("inlineCode",{parentName:"li"},"Response"),"?")),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u041a\u043e\u0434 \u043e\u0442\u0432\u0435\u0442\u0430;"),Object(l.b)("li",{parentName:"ul"},"\u0423\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043e\u0442\u0432\u0435\u0442\u0430;"),Object(l.b)("li",{parentName:"ul"},"\u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430;")),Object(l.b)("h2",{id:"\u0441\u0441\u044b\u043b\u043a\u0438"},"\u0421\u0441\u044b\u043b\u043a\u0438"),Object(l.b)("ol",null,Object(l.b)("li",{parentName:"ol"},Object(l.b)("a",Object(n.a)({parentName:"li"},{href:"https://learn.javascript.ru/fetch"}),"Learn JavaScript")),Object(l.b)("li",{parentName:"ol"},Object(l.b)("a",Object(n.a)({parentName:"li"},{href:"https://developer.mozilla.org/ru/docs/Web/API/Fetch_API/Using_Fetch"}),"MDN Web Docs")),Object(l.b)("li",{parentName:"ol"},Object(l.b)("a",Object(n.a)({parentName:"li"},{href:"https://www.javascripttutorial.net/javascript-fetch-api/"}),"JS Tutorial"))),Object(l.b)("h2",{id:"contributors-"},"Contributors \u2728"),Object(l.b)("p",null,"Thanks goes to these wonderful people (",Object(l.b)("a",Object(n.a)({parentName:"p"},{href:"https://allcontributors.org/docs/en/emoji-key"}),"emoji key"),"):"),Object(l.b)("table",null,Object(l.b)("tr",null,Object(l.b)("td",{align:"center"},Object(l.b)("a",{href:"https://github.com/IIo3iTiv"},Object(l.b)("img",{src:"https://avatars1.githubusercontent.com/u/72025062?v=4?s=200",width:"200px;",alt:""}),Object(l.b)("br",null),Object(l.b)("sub",null,Object(l.b)("b",null,"IIo3iTiv"))),Object(l.b)("br",null),Object(l.b)("a",{href:"https://github.com/gHashTag/react-native-village/commits?author=IIo3iTiv",title:"Documentation"},"\ud83d\udcd6")),Object(l.b)("td",{align:"center"},Object(l.b)("a",{href:"https://fullstackserverless.github.io/"},Object(l.b)("img",{src:"https://avatars0.githubusercontent.com/u/6774813?v=4?s=200",width:"200px;",alt:""}),Object(l.b)("br",null),Object(l.b)("sub",null,Object(l.b)("b",null,"Dmitriy Vasilev"))),Object(l.b)("br",null),Object(l.b)("a",{href:"#financial-gHashTag",title:"Financial"},"\ud83d\udcb5")))),Object(l.b)("p",null,Object(l.b)("a",Object(n.a)({parentName:"p"},{href:"https://www.patreon.com/bePatron?u=31769291"}),Object(l.b)("img",{alt:"Become a Patron!",src:a(174).default}))))}p.isMDXComponent=!0}}]);