{"id":300495,"date":"2020-03-21T09:00:12","date_gmt":"2020-03-21T09:00:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=300495"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=300495","title":{"rendered":"\u041e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/493206\/\">\u2026 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xx\/rv\/-h\/xxrv-hwji9ew9iolkoayzvmfb5m.jpeg\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u0432 JavaScript \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u044b:<\/p>\n<ul>\n<li>XMLHttpRequest<\/li>\n<li>JQuery.ajax<\/li>\n<li>Qwest<\/li>\n<li>SuperAgent<\/li>\n<li>Http-client<\/li>\n<li>Axios<\/li>\n<li>Fetch<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 GET \u0438 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445 \u0438 \u043c\u0438\u043d\u0443\u0441\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430.<\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c XMLHttpRequest, Axios \u0438 Fetch.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>XMLHttpRequest<\/h3>\n<p>  \u041e\u0431\u044a\u0435\u043a\u0442 XMLHttpRequest \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u0440\u0435\u0439\u0448\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0442 \u0435\u0433\u043e \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c (\u0432 \u0447\u0435\u043c \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c) \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438. \u041d\u0435\u043b\u044c\u0437\u044f \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043e \u0435\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (\u0447\u0443\u0442\u044c \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u00ab\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0435\u00bb).<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">let xhr = new XMLHttpRequest()  xhr.open('GET', 'https:\/\/example.com\/users')  xhr.send()  xhr.onload = function() {   if (xhr.status != 200) {     console.log(`error ${xhr.status}: ${xhr.statusText}`)   } else {     \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438     console.log(xhr.response)   } }  xhr.onerror = function() {   \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 } <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">let formData = new FormData()  formData.append('name', 'Harry')  let xhr = new XMLHttpRequest(); xhr.open('POST', 'https:\/\/example.com\/users'); xhr.send(formData);  xhr.onload = () =&gt; console.log(xhr.response); <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043e \u0432\u0441\u0435\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445<\/li>\n<li>\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c API \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/li>\n<li>\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<li>\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043d\u0435\u0443\u043a\u043b\u044e\u0436\u0438\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/li>\n<li>\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u00ab\u0430\u0434\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430\u00bb<\/li>\n<li>\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 fetch \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><a href=\"https:\/\/api.jquery.com\/jquery.ajax\/\" rel=\"nofollow\">JQuery.ajax<\/a><\/h3>\n<p>  \u042d\u0442\u043e \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0441 \u0434\u0430\u0432\u043d\u0438\u0445 \u043f\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  \u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b ajax \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e (\u043d\u0430\u0434\u0441\u0442\u0440\u043e\u0439\u043a\u0443) \u043d\u0430\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c XMLHttpRequest.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">$.ajax({     url: 'https:\/\/example.com\/users' }).done(function(data) {     \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438     console.log(data) }).fail(function(error) {     \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438     console.log(error) }) <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">$.ajax({   method: &quot;POST&quot;,   url: &quot;https:\/\/example.com\/users&quot;,   data: { name: 'Harry', age: 29 } })   .done(function(msg) {     console.log( 'data saved: ' + msg );   }) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u0445\u043e\u0440\u043e\u0448\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/li>\n<li>\u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445<\/li>\n<li>\u043f\u0440\u043e\u0441\u0442 \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438<\/li>\n<li>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c API \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<li>\u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b JQuery<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.npmjs.com\/package\/qwest\" rel=\"nofollow\">Qwest<\/a><\/h3>\n<p>  Qwest \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f ajax-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0430\u044f \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 XmlHttpRequest2, \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 ArrayBuffer, Blob \u0438 FormData.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">qwest.get('https:\/\/example.com\/users')      .then(function(xhr, response) {         \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438         console.log(response)      }); <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">qwest.post('https:\/\/example.com\/users', {         name: 'Harry',         age: 29     })     .then(function(xhr, response) {         \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438         console.log(response)     })     .catch(function(e, xhr, response) {         \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438         console.log(e)     }) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/li>\n<li>\u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>XmlHttpRequest2 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445<\/li>\n<li>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><a href=\"https:\/\/github.com\/visionmedia\/superagent#browser\" rel=\"nofollow\">Superagent<\/a><\/h3>\n<p>  Superagent (visionmedia) \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438 ajax API, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 node.js.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">const superagent = require('superagent')  superagent   .get('https:\/\/example.com\/users')   .end((err, res) =&gt; {     \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438     console.log(res)   }) <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 query() \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u2014 \u0441\u0442\u0440\u043e\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">superagent.get('https:\/\/example.com\/users')     .query({         name: 'Harry'     })     .query({         age: 29     })     .end(response =&gt; {         console.log(response)     }) <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">superagent.post('https:\/\/example.com\/users')     .send({         name: 'Harry'     })     .set('Accept', 'application\/json')     .end(response =&gt; {         console.log(response)     }) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445<\/li>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u0432 node.js<\/li>\n<li>\u0434\u043b\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 request.abort()<\/li>\n<li>\u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/li>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/li>\n<li>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>Http-client<\/h3>\n<p>  Http-client \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442 HTTP, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Fetch API.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c ES-6 \u043c\u043e\u0434\u0443\u043b\u0438 import {     createFetch,     base,     accept,     parse } from 'http-client'  const fetch = createFetch(     base('https:\/\/example.com\/users'),     accept('application.json'),     parse('json') )  fetch('https:\/\/example.com\/users').then(response =&gt; {     console.log(response.jsonData) }) <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">import {     createFetch,     method,     params } from 'http-client'  const fetch = createFetch(     params({         name: 'Harry'     }),     base('htpps:\/\/example.com\/users') ) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u0432 node.js<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438<\/li>\n<li>\u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445<\/li>\n<li>\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0437\u0430\u0449\u0438\u0442\u0443 \u0432 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><a href=\"https:\/\/github.com\/axios\/axios\" rel=\"nofollow\">Axios<\/a><\/h3>\n<p>  \u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u0432 node.js.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">const axios = require('axios');  axios.get('https:\/\/example.com\/users')   .then(function(response) {     \/\/ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438     console.log(response);   })   .catch(function(error) {     \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438     console.log(error);   }) <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">axios.post('\/user', {     name: 'Harry',     age: 29   })   .then(function(response) {     console.log(response);   })   .catch(function(error) {     console.log(error);   }) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u043c\u0438\u0441\u044b \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00ab\u0430\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430\u00bb<\/li>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0442\u0430\u043a \u0438 \u0432 node.js<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/li>\n<li>\u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430<\/li>\n<li>\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/li>\n<li>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043e\u0442\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u043e\u0432<\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 JSON<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>Fetch<\/h3>\n<p>  Fetch \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c API \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u043c \u043d\u0430 \u0441\u043c\u0435\u043d\u0443 XMLHttpRequest. \u041e\u043d \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 fetch \u043b\u0435\u0436\u0430\u0442 \u043f\u0440\u043e\u043c\u0438\u0441\u044b.<\/p>\n<h4>GET<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">fetch('https:\/\/example.com\/users')   .then(response =&gt; response.json())   .then(result =&gt; console.log(result))) <\/code><\/pre>\n<p>  <\/p>\n<h4>POST<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">fetch('https:\/\/example.com\/users', {         method: 'post',         headers: {             'Accept': 'application\/json'         },         body: JSON.stringify({             name: 'Harry'         })     })     .then(res =&gt; res.json())     .then(res =&gt; console.log(res)) <\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c<\/li>\n<li>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430<\/li>\n<li>\u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u043f\u0440\u043e\u043c\u0438\u0441\u0430\u0445<\/li>\n<li>\u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u043c\u0438<\/li>\n<li>\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 XMLHttpRequest<\/li>\n<li>\u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ul>\n<li>\u0434\u0432\u0443\u0445\u044d\u0442\u0430\u043f\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 .json(). \u0412 Axios \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/li>\n<li>\u043f\u0440\u043e\u043c\u0438\u0441, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 Fetch(), \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0441\u0435\u0442\u044c\u044e. \u0415\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 404 \u0438\u043b\u0438 500, \u043f\u0440\u043e\u043c\u0438\u0441 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f<\/li>\n<li>\u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/li>\n<li>fetch \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u0443\u043a\u0438 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a\u0430\u043a \u043d\u0435\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0435\u0433\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 { credentials: &#8216;same-origin&#8217; } \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a XMLHttpRequest, Fetch \u0438 Axios \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0412 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/jsonplaceholder.typicode.com\/\" rel=\"nofollow\">JSONPlaceholder<\/a> \u2014 \u0444\u0435\u0439\u043a\u043e\u0432\u044b\u0439 \u043e\u043d\u043b\u0430\u0439\u043d REST API \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0443\u0447\u0435\u0431\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445).<\/p>\n<h4>XMLHttpRequest<\/h4>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 XMLHttpRequest \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 let xhr = new XMLHttpRequest()  \/\/ \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 xhr.open('GET', 'https:\/\/jsonplaceholder.typicode.com\/users')  \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 xhr.send()  \/*xhr.onload = function() {     if (xhr.status != 200) {         console.log(`error ${xhr.status}:${xhr.statusText}`)     } else {         console.table(JSON.parse(xhr.response))     } }*\/  \/\/ \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \/\/ \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u0442\u0430\u0442\u0443\u0441 \/\/ \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f, \u043f\u0430\u0440\u0441\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c xhr.onload = () =&gt; xhr.status != 200 ? console.error(xhr.status) : console.table(JSON.parse(xhr.response))  \/\/ \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \/\/ \u0435\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a Content-Length, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 \/\/ \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442 xhr.onprogress = event =&gt; {     if (event.lengthComputable) {         console.dir(`received ${event.loaded} of ${event.total} bytes`)     } else {         console.dir(`received ${event.loaded} bytes`)     } }  \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 xhr.onerror = () =&gt; console.error('error') <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wz\/ec\/_j\/wzec_jvwtwi7pmpa6sdadzqxphk.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example1.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<h4>Fetch<\/h4>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 (\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0441 XMLHttpRequest):<\/p>\n<pre><code class=\"javascript\">fetch('https:\/\/jsonplaceholder.typicode.com\/users')     .then(response =&gt; response.json())     .then(json =&gt; console.table(json))     .catch(error =&gt; console.error(error)) <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mo\/en\/sc\/moenscw57p2lmwjiknvjzhde-nc.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example2.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u041b\u0438\u0431\u043e, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f async\/await:<\/p>\n<pre><code class=\"javascript\">(async () =&gt; {     try {         const response = await fetch('https:\/\/jsonplaceholder.typicode.com\/users')         const data = await response.json()         console.table(data)     } catch (error) {         console.error(error)     } finally {         console.log('done')     } })() <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sr\/x-\/wr\/srx-wra4dvjy8d2i1pbr4not6bw.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example3.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443: \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0433\u0430\u043b\u0435\u0440\u0435\u044e.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">const url = 'https:\/\/jsonplaceholder.typicode.com\/photos\/'  getPhotosAndMakeGallery(url)  function getPhotosAndMakeGallery(url) {     for (let i = 1; i &lt; 11; i++) {         fetch(url + i)             .then(response =&gt; response.json())             .then(photo =&gt; {                 let img = document.createElement('img')                 img.src = photo.url                 document.body.append(img)             })     } } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p8\/cu\/gg\/p8cuggysa96daaep49tkmawykau.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example4.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<h3>Axios<\/h3>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &lt;script src=\u00ab<a href=\"https:\/\/unpkg.com\/axios\/dist\/axios.min.js\" rel=\"nofollow\">unpkg.com\/axios\/dist\/axios.min.js<\/a>\u00bb&gt;&lt;\/script&gt; \u0432 head \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">axios.get('https:\/\/jsonplaceholder.typicode.com\/users')     .then(response =&gt; console.table(response.data))     .catch(error =&gt; console.log(error)) <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example5.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u041b\u0438\u0431\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 async\/await:<\/p>\n<pre><code class=\"javascript\">(async () =&gt; {     try {         const response = await axios.get('https:\/\/jsonplaceholder.typicode.com\/users');         console.table(response.data);     } catch (error) {         console.error(error);     } })() <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example6.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u0423\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c todos \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">const url = 'https:\/\/jsonplaceholder.typicode.com\/todos\/'  getTodosAndMakeList()  function getTodosAndMakeList() {     const ul = document.createElement('ul')     document.body.append(ul)      for (let i = 1; i &lt; 21; i++) {         axios.get(url + i)             .then(response =&gt; {                 let li = document.createElement('li')                 li.textContent = `title: ${response.data.title}; completed: ${response.data.completed}`                 ul.append(li)             })             .catch(error =&gt; console.log(error))     } } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cd\/er\/wp\/cderwpwsy4pq0-6_xh77g5-7hly.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example7.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u0415\u0449\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u043c: \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u0444\u043e\u0442\u043e, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0432 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">function getUsers(i) {     return axios.get('https:\/\/jsonplaceholder.typicode.com\/users\/' + i) }  function getComments(i) {     return axios.get('https:\/\/jsonplaceholder.typicode.com\/comments\/' + i) }  function getPhotos(i) {     return axios.get('https:\/\/jsonplaceholder.typicode.com\/photos\/' + i) }  (async() =&gt; {     for (let i = 1; i &lt; 7; i++) {         let request = await axios.all([getUsers(i), getComments(i), getPhotos(i)])             .then(axios.spread(function(user, comment, photo) {                 let figure = document.createElement('figure')                 document.body.append(figure)                 let figcaption = document.createElement('figcaption')                 figcaption.textContent = `Post ${i}`                 figure.append(figcaption)                  let img = document.createElement('img')                 img.src = photo.data.url                 figure.append(img)                  let userName = document.createElement('p')                 userName.innerHTML = `&lt;span&gt;Name:&lt;\/span&gt; ${user.data.username}`                 figure.append(userName)                  let userComment = document.createElement('p')                 userComment.innerHTML = `&lt;span&gt;Comment:&lt;\/span&gt; ${comment.data.body}`                 figure.append(userComment)             }))     } })() <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_7\/41\/6c\/_7416c-cmwdjnajtccs7fd1fqyo.png\"><\/p>\n<p>  \u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/request-examples\/blob\/master\/request-example8.html\" rel=\"nofollow\">GitHub<\/a>.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u0421\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u043d\u0433\u0430!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/493206\/\"> https:\/\/habr.com\/ru\/post\/493206\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/493206\/\">\u2026 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0432\u0435\u0442, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xx\/rv\/-h\/xxrv-hwji9ew9iolkoayzvmfb5m.jpeg\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u0432 JavaScript \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u0435\u043c\u044b:<\/p>\n<ul>\n<li>XMLHttpRequest<\/li>\n<li>JQuery.ajax<\/li>\n<li>Qwest<\/li>\n<li>SuperAgent<\/li>\n<li>Http-client<\/li>\n<li>Axios<\/li>\n<li>Fetch<\/li>\n<\/ul>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 GET \u0438 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u043b\u044e\u0441\u0430\u0445 \u0438 \u043c\u0438\u043d\u0443\u0441\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430.<\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c XMLHttpRequest, Axios \u0438 Fetch.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-300495","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=300495"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300495\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}