{"id":438,"date":"2017-07-24T00:55:18","date_gmt":"2017-07-23T22:55:18","guid":{"rendered":"http:\/\/ahmadmagdy.me\/blog\/?p=438"},"modified":"2017-07-24T02:27:28","modified_gmt":"2017-07-24T00:27:28","slug":"%d8%aa%d8%b9%d8%b1%d9%81-%d8%b9%d9%84%d9%89-httpclient-%d9%81%d9%8a-angular-4-3","status":"publish","type":"post","link":"https:\/\/magdy.dk\/arblog\/?p=438","title":{"rendered":"\u062a\u0639\u0631\u0641 \u0639\u0644\u0649 HttpClient \u0641\u064a Angular 4.3"},"content":{"rendered":"<p><span style=\"font-size: 14pt;\">\u0627\u0644\u0633\u0644\u0627\u0645 \u0639\u0644\u064a\u0643\u0645<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u0641\u064a \u0627\u0644\u0627\u0635\u062f\u0627\u0631 \u0627\u0644\u0627\u062d\u062f\u062b \u0645\u0646 Angular \u00a0\u0631\u0642\u0645 4.3 \u062a\u0645 \u062a\u0642\u062f\u064a\u0645 module \u062c\u062f\u064a\u062f \u064a\u062f\u0639\u0649\u00a0HttpClient \u0627\u062a\u0649 \u0628\u062a\u0637\u0648\u064a\u0631\u0627\u062a \u0648\u062a\u062d\u062f\u064a\u062b\u0627\u062a \u0644\u0644module \u0627\u0644\u0633\u0627\u0628\u0642 \u0644\u0647\u00a0HttpModule<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u0625\u0630\u0627\u064b \u0645\u0627\u0644\u062c\u062f\u064a\u062f \u061f<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 14pt;\">\u00a0 &#8211; \u0644\u0633\u062a \u0641\u064a \u062d\u0627\u062c\u0629 \u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644 Response \u0644 json \u0633\u064a\u062a\u0645 \u062a\u062d\u0648\u064a\u0644\u0647 \u062a\u0644\u0642\u0627\u0626\u064a\u0627\u064b, \u0641\u064a \u0627\u0644\u0633\u0627\u0628\u0642 \u0639\u0646\u062f \u0637\u0644\u0628 \u0631\u0627\u0628\u0637 \u0645\u0639\u064a\u0646 \u0648\u0627\u0644\u0627\u0634\u062a\u0631\u0627\u0643 \u0641\u064a \u0627\u0644\u0631\u062f \u0643\u0646\u0627 \u0646\u0636\u0637\u0631 \u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0631\u062f \u064a\u062f\u0648\u064a\u0627\u064b \u0644json \u062d\u062a\u0649 \u0646\u0633\u062a\u0637\u064a\u0639 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0645\u062b\u0627\u0644<\/span>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nthis.http.get('https:\/\/url.dom\/tt')\r\n.map(res =&gt; res.json)\r\n.subscript(res =&gt; {\r\nconsole.log(res);\r\n})\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u0625\u0630\u0627 \u0644\u0645 \u0646\u0642\u0645 \u0628\u062a\u062d\u0648\u064a\u0644\u0647 \u0642\u0628\u0644 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0641\u064a map \u0627\u0648 \u062d\u062a\u0649 \u0639\u0646 \u0627\u0644\u0627\u0634\u062a\u0631\u0627\u0643 \u0644\u0646 \u0646\u0633\u062a\u0637\u064a\u0639 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0643json<\/span><br \/>\n<span style=\"font-size: 14pt;\"> \u0627\u0644\u0627\u0646 \u0628\u0639\u062f \u0627\u0633\u062a\u062e\u062f\u0627\u0645 HttpClient \u0644\u0646 \u0646\u0633\u062a\u062e\u062f\u0645 \u0647\u0630\u0627 \u0627\u0644\u0633\u0637\u0631 \u0648\u0633\u064a\u0635\u0628\u062d \u0645\u0628\u0627\u0634\u0631\u0629<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nthis.http.get('https:\/\/url.dom\/tt')\r\n.subscripe(res=&gt; console.log(res));\r\n<\/pre>\n<\/li>\n<li><span style=\"font-size: 14pt;\">\u00a0&#8211; \u0628\u0645\u0627 \u0627\u0646 \u0627\u0644\u0631\u062f &#8220;Response&#8221; \u0627\u0644\u0642\u0627\u062f\u0645 \u0627\u0635\u0628\u062d \u0628\u0635\u064a\u063a\u0629 json \u0645\u0628\u0627\u0634\u0631\u0629 \u0641\u0628\u062a\u0627\u0644\u064a \u064a\u0645\u0643\u0646\u0646\u0627 \u062a\u062d\u062f\u064a\u062f \u0646\u0648\u0639 \u0644\u0647, \u0645\u062b\u0644\u0627\u064b \u0639\u0646\u062f \u0637\u0644\u0628 \u062a\u0633\u062c\u064a\u0644 \u0627\u0644\u062f\u062e\u0648\u0644 \u0648\u0639\u0646\u062f \u0646\u062c\u0627\u062d \u0627\u0644\u0637\u0644\u0628 \u0641\u0645\u0646 \u0627\u0644\u0645\u062a\u0648\u0642\u0639 \u0627\u0646 \u064a\u0631\u062c\u0639 \u0644\u0646\u0627 \u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645 \u0648\u0628\u062f\u0644\u0627\u064b \u0645\u0646 \u0639\u0645\u0644 bind \u0644\u0647\u0627 \u064a\u062f\u0648\u064a\u0627\u064b \u0627\u0635\u0628\u062d \u0628\u0625\u0645\u0643\u0627\u0646\u0646\u0627 \u0627\u0644\u0639\u0645\u0644 \u0628\u0647\u0630\u0627 \u0627\u0644\u0634\u0643\u0644<\/span>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nthis.http.post&lt;IUser&gt;('\/api\/auth\/login',{username,password})\r\n\r\n\r\n.subscribe(res=&gt;{\r\n\r\n\r\n\/\/response here will &amp;nbsp;be IUser type\r\n})\r\n\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u0641\u064a \u0627\u0644\u0631\u062f \u0647\u0646\u0627 \u0633\u064a\u062a\u0645 \u062a\u062d\u0648\u064a\u0644\u0647 \u0644\u0646\u0648\u0639 IUser \u0648\u0647\u0648 \u0627\u0644\u0645\u062a\u0648\u0642\u0639 \u0648\u064a\u0645\u0643\u0646\u0646\u0627 \u0628\u0639\u062f\u0647\u0627 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0643\u0645\u0627 \u0646\u0634\u0627\u0621<\/span><\/p>\n<blockquote><p><span style=\"font-size: 10pt;\">\u0645\u0644\u0627\u062d\u0638\u0629: IUser \u0627\u0646\u0627 \u0642\u0645\u062a \u0628\u0627\u0646\u0634\u0627\u0621\u0647 \u0648\u0647\u0648 \u0639\u0628\u0627\u0631\u0629 \u0639\u0646 Interface \u062a\u062d\u062a\u0648\u064a \u0639\u0644\u0649 \u062e\u0635\u0627\u0626\u0635 \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645 \u0627\u0644\u0627\u0633\u0627\u0633\u064a\u0629 \u0645\u062b\u0644 name,email,.. \u0648\u063a\u064a\u0631\u0647\u0627<\/span><\/p><\/blockquote>\n<p>&nbsp;<\/li>\n<li><\/li>\n<\/ul>\n<p><span style=\"font-size: 14pt;\">\u0643\u064a\u0641 \u064a\u0645\u0643\u0646\u0643 \u0627\u0644\u0628\u062f\u0621 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u0627\u0644\u0623\u0645\u0631 \u0628\u0633\u064a\u0637 \u062c\u062f\u0627\u064b<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u0641\u064a \u0627\u0644\u0628\u062f\u0627\u064a\u0629 \u0642\u0645 \u0628\u0627\u0633\u062a\u064a\u0631\u0627\u062f\u0647\u0627 \u0641\u064a app.module.ts \u0627\u0644\u062e\u0627\u0635 \u0628\u0643<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n import { HttpClientModule } from '@angular\/common\/http'\r\n\/\/\/\/\/\/\/\r\n imports: &#x5B;\r\n .....\r\n HttpClientModule\r\n ]\r\n <\/pre>\n<p><span style=\"font-size: 14pt;\">\u0628\u0639\u062f \u0630\u0644\u0643 \u064a\u0645\u0643\u0646\u0643 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647\u0627 \u0643\u0645\u0627 \u0643\u0646\u062a \u062a\u0633\u062a\u062e\u062f\u0645 Http<\/span><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport { HttpClient} from '@angular\/common\/http';\r\n\r\nconstructor(private http: HttpClient){}\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u0648\u0644\u0645\u0639\u0631\u0641\u0629 \u0627\u0644\u0645\u0632\u064a\u062f \u0639\u0646 HttpClient \u064a\u0645\u0643\u0646\u0643 \u0632\u064a\u0627\u0631\u0629 \u0627\u0644\u062a\u0648\u064a\u062b\u0642 \u0627\u0644\u0631\u0633\u0645\u064a <a href=\"https:\/\/angular.io\/guide\/http\">Angular<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644\u0633\u0644\u0627\u0645 \u0639\u0644\u064a\u0643\u0645 \u0641\u064a \u0627\u0644\u0627\u0635\u062f\u0627\u0631 \u0627\u0644\u0627\u062d\u062f\u062b \u0645\u0646 Angular \u00a0\u0631\u0642\u0645 4.3 \u062a\u0645 \u062a\u0642\u062f\u064a\u0645 module \u062c\u062f\u064a\u062f \u064a\u062f\u0639\u0649\u00a0HttpClient \u0627\u062a\u0649 \u0628\u062a\u0637\u0648\u064a\u0631\u0627\u062a \u0648\u062a\u062d\u062f\u064a\u062b\u0627\u062a \u0644\u0644module \u0627\u0644\u0633\u0627\u0628\u0642 \u0644\u0647\u00a0HttpModule \u0625\u0630\u0627\u064b \u0645\u0627\u0644\u062c\u062f\u064a\u062f \u061f \u00a0 &#8211; \u0644\u0633\u062a \u0641\u064a \u062d\u0627\u062c\u0629 \u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644 Response \u0644 json \u0633\u064a\u062a\u0645 \u062a\u062d\u0648\u064a\u0644\u0647 \u062a\u0644\u0642\u0627\u0626\u064a\u0627\u064b, \u0641\u064a \u0627\u0644\u0633\u0627\u0628\u0642 \u0639\u0646\u062f \u0637\u0644\u0628 \u0631\u0627\u0628\u0637 \u0645\u0639\u064a\u0646 \u0648\u0627\u0644\u0627\u0634\u062a\u0631\u0627\u0643 \u0641\u064a \u0627\u0644\u0631\u062f \u0643\u0646\u0627 \u0646\u0636\u0637\u0631 \u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0631\u062f \u064a\u062f\u0648\u064a\u0627\u064b \u0644json \u062d\u062a\u0649 \u0646\u0633\u062a\u0637\u064a\u0639 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0645\u062b\u0627\u0644 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[23],"tags":[24],"class_list":["post-438","post","type-post","status-publish","format-standard","hentry","category-23","tag-angular"],"aioseo_notices":[],"views":921,"_links":{"self":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=438"}],"version-history":[{"count":23,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":462,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=\/wp\/v2\/posts\/438\/revisions\/462"}],"wp:attachment":[{"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/magdy.dk\/arblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}