<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yassine BENNKHAY</title>
    <description>The latest articles on DEV Community by Yassine BENNKHAY (@yassine_dev).</description>
    <link>https://dev.to/yassine_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F460629%2Fd36ff3cc-a29f-42b2-8aeb-a97b8686525d.png</url>
      <title>DEV Community: Yassine BENNKHAY</title>
      <link>https://dev.to/yassine_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yassine_dev"/>
    <language>en</language>
    <item>
      <title>Build and deploy a domain name info checker API with Node Js and Express Js</title>
      <dc:creator>Yassine BENNKHAY</dc:creator>
      <pubDate>Thu, 09 Mar 2023 00:22:20 +0000</pubDate>
      <link>https://dev.to/yassine_dev/build-and-deploy-a-domain-name-info-checker-api-with-node-js-and-expressjs-31c7</link>
      <guid>https://dev.to/yassine_dev/build-and-deploy-a-domain-name-info-checker-api-with-node-js-and-expressjs-31c7</guid>
      <description>&lt;p&gt;This post was created originally on &lt;a href="https://yassinebenkhay.com/domain-name-checker-api/"&gt;my website&lt;/a&gt;.&lt;br&gt;
Have you ever wondered how you find any domain name information? I think you did! and it's pretty easy to google it in seconds to find a bunch of websites that offer domain name information, but in this article, we're going to create our own NodeJs and ExpressJs API that will return us the info of any given domain name.&lt;/p&gt;

&lt;p&gt;The structure of our API will have an &lt;code&gt;apiController&lt;/code&gt; that has a &lt;code&gt;getDomainInfo&lt;/code&gt; method, an &lt;code&gt;apiRoute&lt;/code&gt;, and the entry point of our API which is &lt;code&gt;server.js&lt;/code&gt;--This is just how I like to organize my code, otherwise, you can write all the logic in one file, but I don't recommend it:)&lt;/p&gt;

&lt;p&gt;Sound exciting enough? so Let's get right into it!&lt;/p&gt;

&lt;p&gt;The project folder structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;domain_checker_api&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;node_modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;routes&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt;    &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;apiRoute&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;controllers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt;    &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;apiController&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="kr"&gt;package&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="kr"&gt;package&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;
  &lt;span class="o"&gt;|-&lt;/span&gt; &lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to follow up make sure to have NodeJs installed on your machine, or you can install it from &lt;a href="//nodejs.org"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So the first step is to install some dependencies &lt;code&gt;express&lt;/code&gt;  , &lt;code&gt;dotenv&lt;/code&gt; and &lt;code&gt;whois-json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In your terminal run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install express whois-json dotenv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In our &lt;code&gt;server.js&lt;/code&gt; file let's set up our Express server:&lt;/p&gt;

&lt;p&gt;First, we require express module and create an express app instance using the &lt;code&gt;express( )&lt;/code&gt; function, and define the port that our server will listen to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The port will be in a separate file and we access it by process.env.PORT.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up the route for the request that starts with&lt;code&gt;"/api/v1/domain"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;we use &lt;code&gt;app.use()&lt;/code&gt;to mount the router that will be defined in&lt;code&gt;"./routes/apiRoute"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;apiRoute&lt;/code&gt;file will be created later on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/v1/domain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./routes/apiRoute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the server and listen to any incoming requests on the specified port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server is Running on the Port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server.js&lt;br&gt;
 should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/v1/domain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./routes/apiRoute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Server is Running on the Port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our server is up and running, let’s create &lt;code&gt;apiController.js&lt;/code&gt; file that has a getDomainInfo method that will retrieve the domain info.&lt;/p&gt;

&lt;p&gt;first thing first let’s require the necessary modules;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dns&lt;/code&gt;is a built-in NodeJs module that resolves domain names to IP addresses and the &lt;code&gt;whois-json&lt;/code&gt; is a third-party library that allows us to retrieve WHOIS information in JSON format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dns&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;whois&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;whois-json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We define a method called &lt;code&gt;getDomainInfo&lt;/code&gt;that takes as a parameter &lt;code&gt;req&lt;/code&gt; and &lt;code&gt;res&lt;/code&gt;objects&lt;/p&gt;

&lt;p&gt;then we extract the domain from the request parameters and store it in the &lt;code&gt;domain&lt;/code&gt;variable.&lt;/p&gt;

&lt;p&gt;we use &lt;code&gt;dns.lookup&lt;/code&gt; method to resolve the domain into an IP address.&lt;/p&gt;

&lt;p&gt;If there is an error we return the 400 status code with the error message as JSON.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;domain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;dns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything went okay we store the domain and the ip address in the &lt;code&gt;data&lt;/code&gt;variable.&lt;/p&gt;

&lt;p&gt;Now that we have the IP address we can use the &lt;code&gt;whois-json&lt;/code&gt; module to retrieve additional information about the domain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;whois&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and return the info as a JSON object like follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrarUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrarUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;nameServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nameServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;creationDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;creationDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;updatedDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;expirationDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrarRegistrationExpirationDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrantName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrantName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrantCountry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrantCountry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;adminName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adminName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;adminPhone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adminPhone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;defining a &lt;code&gt;welcome&lt;/code&gt;method that returns a JSON welcome message to the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;welcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome to the domain name API checker, hit the endpoint /api/v1/domain/ and type your domain name without https:// to get the domain info.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we export the &lt;code&gt;getDomainInfo&lt;/code&gt; and the &lt;code&gt;welcome&lt;/code&gt;methods so that we can use them in the router.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;welcome&lt;/span&gt;

&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the &lt;code&gt;apiController.js&lt;/code&gt; file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dns&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;whois&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;whois-json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;domain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;dns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// whois domain info&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;whois&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrarUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrarUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;nameServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nameServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;creationDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;creationDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;updatedDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;updatedDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;expirationDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrarRegistrationExpirationDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrantName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrantName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;registrantCountry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registrantCountry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;adminName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adminName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;adminPhone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;adminPhone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;welcome&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let’s work on the route.&lt;/p&gt;

&lt;p&gt;In the&lt;code&gt;apiRoute.js&lt;/code&gt; file we require &lt;code&gt;getDomainInfo&lt;/code&gt; from &lt;code&gt;apiController&lt;/code&gt; file, express and create a &lt;code&gt;router&lt;/code&gt;instance using &lt;code&gt;express.Router()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../controllers/apiController&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up a GET route for the endpoint &lt;code&gt;"/api/v1/domain/:domain"&lt;/code&gt;. When a GET request is made to this endpoint the router will call the &lt;code&gt;getDomainInfo&lt;/code&gt;passing in the domain parameter from the request URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/v1/domain/:domain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the root of the API is a welcome message when a request is made to the root &lt;code&gt;“/”&lt;/code&gt; the welcome method gets called.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;apiRoute.js&lt;/code&gt; file should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;welcome&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../controllers/apiController&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/v1/domain/:domain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getDomainInfo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;welcome&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to test our API we run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;node server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and go to our browser and type:&lt;code&gt;http://localhost:8080&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;you should see something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ws9TQxld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2g348iwzw5vnx1085iv6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ws9TQxld--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2g348iwzw5vnx1085iv6.jpg" alt="Api root" width="880" height="497"&gt;&lt;/a&gt;&lt;br&gt;
Let’s say that we want to get information about my domain name &lt;code&gt;yassinebenkhay.com&lt;/code&gt; we hit the endpoint :&lt;code&gt;http://localhost:8080/api/v1/domain/yassinebenkhay.com&lt;/code&gt; and we should see the information below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0xn2C41Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk53yneoa476l3158blg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0xn2C41Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk53yneoa476l3158blg.png" alt="API response" width="880" height="491"&gt;&lt;/a&gt;&lt;br&gt;
The final step is to deploy this API to a hosting service, I think the easiest way to do so is with Heroku, so let’s go with that.&lt;/p&gt;

&lt;p&gt;In your Heroku account create a new app like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ICkwc6US--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqpw24rel1pthd5qqw2x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ICkwc6US--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zqpw24rel1pthd5qqw2x.jpg" alt="Link repo with heroku app" width="880" height="473"&gt;&lt;/a&gt;&lt;br&gt;
now we need to push the project from our local machine to GitHub.&lt;/p&gt;

&lt;p&gt;in your GitHub account create a new repo and push the project to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--taxLUJmx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykkfs91t88b00ndz5216.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--taxLUJmx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykkfs91t88b00ndz5216.jpg" alt="GitHub repo" width="880" height="473"&gt;&lt;/a&gt;&lt;br&gt;
Don’t remove node_modules when you upload the project to the repo, otherwise, the API won’t work once we link the repo with Heroku.&lt;/p&gt;

&lt;p&gt;Also, you need to add the node js version in your package.json file in order for Heroku to download it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="p"&gt;...&lt;/span&gt;
 &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;engines&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;v16.x&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now go to Heroku and like the repo, with the app, we have just created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kxJWGt4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jrl9v6vhvznvm2oerwa4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kxJWGt4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jrl9v6vhvznvm2oerwa4.png" alt="link app with repo" width="880" height="473"&gt;&lt;/a&gt;&lt;br&gt;
After the repo and the app are linked click deploy as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ON5DOI8K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8e37lc1d9v3h3ir1csr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ON5DOI8K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8e37lc1d9v3h3ir1csr.png" alt="deploy" width="880" height="436"&gt;&lt;/a&gt;&lt;br&gt;
Wait for the process to finish, If everything went well you will have your API link just like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://domain-name-checker-api.herokuapp.com/"&gt;https://domain-name-checker-api.herokuapp.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope that this Tutorial was helpful, if you have any suggestions please consider dropping them in the comments section below.&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>api</category>
      <category>heroku</category>
    </item>
    <item>
      <title>Flutter Roadmap | How To Learn Flutter In 2022 The Right Way</title>
      <dc:creator>Yassine BENNKHAY</dc:creator>
      <pubDate>Wed, 24 Aug 2022 19:17:49 +0000</pubDate>
      <link>https://dev.to/yassine_dev/flutter-roadmap-how-to-learn-flutter-in-2022-the-right-way-j43</link>
      <guid>https://dev.to/yassine_dev/flutter-roadmap-how-to-learn-flutter-in-2022-the-right-way-j43</guid>
      <description>&lt;p&gt;This &lt;a href="https://yassinebenkhay.com/flutter-roadmap-best-flutter-courses/" rel="noopener noreferrer"&gt;Article&lt;/a&gt; was published originally on my own blog &lt;a href="https://yassinebenkhay.com" rel="noopener noreferrer"&gt;yassinebenkhay.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With the growth and popularity Flutter is getting, many people are trying to learn it, but it is confusing for beginners to find the best Flutter Roadmap to learn flutter in 2022 the right way, In this article, I will provide you with all the resources and courses you’ll ever need to learn Flutter, but before getting started, let’s know what’s flutter.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Flutter?
&lt;/h2&gt;

&lt;p&gt;Flutter is one of the most famous frameworks nowadays for mobile application developments, In this post, I will show you a step-by-step roadmap on how to learn flutter the right way, 500k apps built using Flutter since its first release in 2018 and this tells the power Flutter has been gained so quickly.&lt;br&gt;
If you’re here that means you want a clear roadmap that you will follow to learn flutter.&lt;/p&gt;

&lt;p&gt;Before thinking to learn Flutter you definitely should Learn its programming language Dart even if you have a programming background.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should you learn Flutter?
&lt;/h2&gt;

&lt;p&gt;Most beginners get confused when it comes to which Mobile apps framework/programming language to choose and learn.&lt;br&gt;
Here are some of the solid reason that makes Flutter worth learning:&lt;br&gt;
With Flutter, you can create Mobile apps that work on Android, iOS, and desktop apps that work on macOS, Linux, Windows, and the web, isn’t that amazing?&lt;br&gt;
There are several top apps built with flutter like the Xianyu app by Alibaba, google ads app, Philips Hue by BMW, etc.&lt;br&gt;
Flutter has huge community support and it’s growing fast!&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn Dart First!
&lt;/h2&gt;

&lt;p&gt;Since Flutter is built on top of Dart programming language, having the basics of Dart is necessary.&lt;br&gt;
There are several courses and websites you can learn Dart from but I’ll address here the most beginner-friendly ones, here are some paid courses:&lt;br&gt;
&lt;a href="https://dev.toThe%20Complete%20Dart%20Language%20Guide%20for%20Beginners%20and%20Beyond"&gt;The Complete Dart Language Guide for Beginners and Beyond&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c1yavban5po9tbj6zy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c1yavban5po9tbj6zy0.png" alt="The Complete Dart Language Guide for Beginners and Beyond"&gt;&lt;/a&gt;&lt;br&gt;
This course is created by Andrea Bizzotto, as a beginner in mobile developments, this course will teach you Dart Programming in depth. Includes: basic to advanced topics, exercises, and projects. It’s updated to version Dart 2.15.&lt;br&gt;
&lt;a href="https://www.udemy.com/course/dart-from-novice-to-expert/" rel="noopener noreferrer"&gt;Dart - from Novice to Expert Complete Course&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9wwx4q0iuxuheaf16y8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9wwx4q0iuxuheaf16y8.png" alt="Dart - from Novice to Expert Complete Course"&gt;&lt;/a&gt;&lt;br&gt;
In this course, Tiberiu Potec will teach you, Dart, by visualizing the most important concepts of Dart Language, getting deeper into Dart fundamentals, and advanced topics such as sound null safety and OOP.&lt;/p&gt;

&lt;p&gt;Paid courses are great but some of you may not afford them that’s why I collected some good free YouTube channels that teach Flutter and Dart in a great way:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=8D1UK3hq8U8&amp;amp;ab_channel=FullstackSchool" rel="noopener noreferrer"&gt;FullStack School&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Figsglj6rxq56133y0qe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Figsglj6rxq56133y0qe7.png" alt="FullStack School&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;This free Tutorial FullStack School will teach you all the basics of Dart that will allow you to get right into starting learning flutter which provide you best courses in the next paragraphs.&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=Ej_Pcr4uC2Q&amp;amp;t=954s&amp;amp;ab_channel=freeCodeCamp.org" rel="noopener noreferrer"&gt;FreeCodeCamp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntvnneib9xfah0g4qwbm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fntvnneib9xfah0g4qwbm.png" alt="FreeCodeCamp"&gt;&lt;/a&gt;When it comes to learning computer science and programming &lt;a href="https://www.freecodecamp.org/" rel="noopener noreferrer"&gt;FreeCodeCamp&lt;/a&gt; is a great choice, in this Dart Programming Tutorial-Full Course, the instructor is covering Dart from its basics to advanced topics.&lt;br&gt;
&lt;a href="https://www.youtube.com/playlist?list=PL6yRaaP0WPkVR2FiAS7TTCT_n2mDhwISE" rel="noopener noreferrer"&gt;Vandad Nahavandipoor(advanced topics)&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj393223um8bg121g680.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj393223um8bg121g680.png" alt="Vandad Nahavandipoor(advanced topics)&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;br&gt;
Vandad Nahavandipoor in this course dives into Dart in detail and explores all its concepts.&lt;/p&gt;

&lt;p&gt;If you are a reader and you like to learn by reading, I got you covered! here are some good websites to learn Dart from:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dart.dev/tutorials" rel="noopener noreferrer"&gt;Dart's official website&lt;/a&gt; is the first resource I’m addressing, from a personal perspective learning from the official docs is a very good choice for developers who wants to learn things from its sources.&lt;br&gt;
&lt;a href="https://www.tutorialspoint.com/dart_programming/index.htm" rel="noopener noreferrer"&gt;Tutorialspoint&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.javatpoint.com/dart-programming" rel="noopener noreferrer"&gt;Javapoint&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/dart-tutorial/" rel="noopener noreferrer"&gt;geeksforgeeks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After getting familiar with Dart and having surrounded your head about its concepts, It’s time to jump into Flutter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn Flutter
&lt;/h2&gt;

&lt;p&gt;Now let’s take you one step further in your mobile developments journey and start learning Flutter, The courses I will recommend to you, it’s better to take them by order since will take you from the basics of Flutter to Advanced Topics such as State management and how to create complex applications.&lt;br&gt;
So the first course that focuses on the basics of Flutter is &lt;a href="https://www.udemy.com/course/flutter-bootcamp-with-dart/" rel="noopener noreferrer"&gt;The Complete 2021 Flutter Development Bootcamp with Dart&lt;/a&gt; by Dr. Angela Yu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1j2adkblfpgkjjtbkrv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1j2adkblfpgkjjtbkrv5.png" alt="The Complete 2021 Flutter Development Bootcamp with Dart"&gt;&lt;/a&gt;&lt;br&gt;
This course is officially created in collaboration with the google flutter team and it aims to teach especially beginners how to learn flutter in a way that focuses on fundamentals.&lt;br&gt;
Once you took this course and have understood Flutter widgets, how to use them, and created several basics apps, the second course I’d recommend that focus on advanced topics is &lt;br&gt;
&lt;a href="https://www.udemy.com/course/learn-flutter-dart-to-build-ios-android-apps/" rel="noopener noreferrer"&gt;Flutter &amp;amp; Dart - The Complete Guide [2022 Edition] &lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nf2aas75gs2mu6maiqs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6nf2aas75gs2mu6maiqs.png" alt="Flutter &amp;amp; Dart - The Complete Guide [2022 Edition] "&gt;&lt;/a&gt;&lt;br&gt;
In this course, Maximilian Schwarzmüller teaches you Flutter and Dart in a depth, besides that he always tries to make you feel the importance of writing &lt;a href="https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882" rel="noopener noreferrer"&gt;clean code&lt;/a&gt; and structuring the application so it will be easy to maintain in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;By taking the courses above you will be ready to jump into practicing by yourself, and build stuff because let’s be honest, taking the courses will not take you that far if you don’t put the knowledge you have learned into practice, the name of the game is consistency and not giving up, fortunately, the &lt;a href="https://flutter.dev/community" rel="noopener noreferrer"&gt;Flutter Community&lt;/a&gt; is very helpful and people there are willing to help, if you find yourself stuck at something don’t get discouraged you can reach out the Community and describe your issue and definitely will find someone who will help you.  &lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
    </item>
    <item>
      <title>Fetch Data from the Internet with Flutter.</title>
      <dc:creator>Yassine BENNKHAY</dc:creator>
      <pubDate>Mon, 26 Apr 2021 16:17:12 +0000</pubDate>
      <link>https://dev.to/yassine_dev/fetch-data-from-the-internet-with-flutter-4742</link>
      <guid>https://dev.to/yassine_dev/fetch-data-from-the-internet-with-flutter-4742</guid>
      <description>&lt;p&gt;&lt;strong&gt;This article was posted in my &lt;a href="https://yassine-bennkhay.tech/"&gt;Blog&lt;/a&gt; also, so I'll be happy if you check it out :)&lt;/strong&gt;&lt;br&gt;
Most apps need to deal with the internet and fetching data from it is necessary. Flutter and Dart provide tools such as the &lt;a href="https://pub.dev/packages/http"&gt;http&lt;/a&gt; package regarding this matter. to fetch data and display it in your app there're steps we'll follow and they're the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;add the http package&lt;/li&gt;
&lt;li&gt;make a network request using http package&lt;/li&gt;
&lt;li&gt;convert the response into a Dart object&lt;/li&gt;
&lt;li&gt;Fetch and display data with Flutter &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article I'm going to use  &lt;a href="https://jsonplaceholder.typicode.com/"&gt;JSONPlaceholder&lt;/a&gt; to fetch a Post using  &lt;a href="https://pub.dev/documentation/http/latest/http/get.html"&gt;http.get( )&lt;/a&gt; method. So let's get Started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1-add the http package:&lt;/strong&gt;&lt;br&gt;
in the pubspec.yaml file adds the latest version of the  &lt;a href="https://pub.dev/packages/http"&gt;http package&lt;/a&gt; and get dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  http: &amp;lt;latest_version&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2-make a network request using http package:&lt;/strong&gt; &lt;br&gt;
we create a method of type ** Future of http.Response*&lt;em&gt;. then we store the Response we get from our **http.get( )&lt;/em&gt;* method in the gettedPost variable .then we check if the gettedPost has data or not through the if statement as you can see in the code snippet below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Future&amp;lt;http.Response&amp;gt; getPostDetails()async{
    http.Response gettedPost=
    await http.get(Uri.https('jsonplaceholder.typicode.com', 'posts/1'),);
    if(gettedPost.statusCode==200){
      //success
print(futurePost.body);//just printing out the data in the console for now!
      return null;
    }else{
//failed for some reason.
      throw Exception('we cant load your data ');
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for testing purposes, I printed out the response in the console first :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fNLzzz6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619448878832/3YE4LbgJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fNLzzz6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619448878832/3YE4LbgJQ.png" alt="carbon (2).png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3-Convert the response into a custom Dart object&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;the &lt;strong&gt;http.Response&lt;/strong&gt; class contains the data received from a successful http call, however, we need to convert it to a custom dart object so we make life easier for us!&lt;br&gt;
for that, we create a Post class that contains the data from the network request.&lt;br&gt;
The Post class contains a  &lt;a href="https://dart.dev/guides/language/language-tour#factory-constructors"&gt;factory constructor&lt;/a&gt; to create a Post.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Post{
  int userId;
      int id;
  String title;
  String body;
  Post({this.body,this.title,this.id,this.userId});
factory Post.fromJson(Map&amp;lt;String,dynamic&amp;gt;comingJson){
  return Post(
    id: comingJson['id'],
    userId: comingJson['userId'],
    title: comingJson['title'],
    body: comingJson['body'],
  );
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now we need to convert the http.Response to a Post using the dart:convert &lt;br&gt;
and update the &lt;em&gt;getPostDetails( )&lt;/em&gt; to return a &lt;em&gt;Future of Post&lt;/em&gt;.&lt;br&gt;
If the server does return an OK response with a status code of 200, then convert the JSON Map into a Post using the fromJson() factory method.&lt;/p&gt;

&lt;p&gt;If the server does not return an OK response with a status code of 200, then throw an exception.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'dart:convert';
  Future&amp;lt;Post&amp;gt; getPostDetails()async{
    http.Response futurePost=
    await http.get(Uri.https('jsonplaceholder.typicode.com', 'posts/1'),);
    if(futurePost.statusCode==200){
    /*if the server return an Ok status code 200 then convert the JSON Map into a Post*/
      return Post.fromJson(jsonDecode(futurePost.body));
    }else{
      /*if the server did not return an status code then throw exception*/
      throw Exception('we cant load your data ');
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Great till now, we're quite close!&lt;br&gt;
&lt;strong&gt;4-Fetch &amp;amp; Display Data:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;to Fetch the data we create a variable to hold the getPostDetails( ) in the initState() method like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Future&amp;lt;Post&amp;gt; postData;
@override
  initState(){
super.initState();
postData=getPostDetails();
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the last thing is to display the data in the user interface and for that, we'll use  &lt;a href="https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html"&gt; FutureBuilder&lt;/a&gt; widget and give it the future parameter you want to work with, in this case, getPostDetails( ) and the builder function that tells Flutter what to render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FutureBuilder(
          future: postData,
          builder: (context,snapShot){
           if(snapShot.hasData){
             return Padding(
               padding: const EdgeInsets.all(8.0),
               child: Column(
                 children: [
               Text('the user id is: ${snapShot.data.userId}'),
                   Text('the id is : ${snapShot.data.id}'),
                   Text('the title is : ${snapShot.data.title}'),
                   Text('the body is: ${snapShot.data.body}'),
                 ],
               ),
             );
           }else if(snapShot.hasError){
             return Text("${snapShot.error}");
           }
           return CircularProgressIndicator();
          },
        ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Complete Example:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  The Post Model:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Post{
  int userId;
      int id;
  String title;
  String body;
  Post({this.body,this.title,this.id,this.userId});
factory Post.fromJson(Map&amp;lt;String,dynamic&amp;gt;comingJson){
  return Post(
    id: comingJson['id'],
    userId: comingJson['userId'],
    title: comingJson['title'],
    body: comingJson['body'],
  );
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  main ( ):
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart 'as http;

import 'model/post.dart';
void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() =&amp;gt; _MyHomePageState();
}
class _MyHomePageState extends State&amp;lt;MyHomePage&amp;gt; {
  Future&amp;lt;Post&amp;gt; postData;
@override
  initState(){
super.initState();
postData=getPostDetails();
  }
  Future&amp;lt;Post&amp;gt; getPostDetails()async{
    http.Response futurePost=
    await http.get(Uri.https('jsonplaceholder.typicode.com', 'posts/1'),);
    if(futurePost.statusCode==200){
    /*if the server return an Ok status code 200 then convert the JSON Map into a Post*/
      return Post.fromJson(jsonDecode(futurePost.body));
    }else{
      /*if the server did not return an status code then throw exception*/
      throw Exception('we cant load your data ');
    }
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
appBar: AppBar(title: Text('getting data from the internet.'),),
      body: Center(
        child:FutureBuilder(
          future: postData,
          builder: (context,snapShot){
           if(snapShot.hasData){
             return Padding(
               padding: const EdgeInsets.all(8.0),
               child: Column(
                 children: [
               Text('the user id is: ${snapShot.data.userId}'),
                   Text('the id is : ${snapShot.data.id}'),
                   Text('the title is : ${snapShot.data.title}'),
                   Text('the body is: ${snapShot.data.body}'),
                 ],
               ),
             );
           }else if(snapShot.hasError){
             return Text("${snapShot.error}");
           }
           return CircularProgressIndicator();
          },
        ),
      ),
    );
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alright! that was how to fetch a simple Post from the Internet with Flutter.&lt;/p&gt;

&lt;p&gt;❤ ❤ Thanks for reading this article ❤❤&lt;/p&gt;

&lt;p&gt;Please If I got something wrong? Let me know in the comments. I would love to improve!&lt;br&gt;
if you find this article helpful click that like button and don't forget to check my &lt;a href="https://www.instagram.com/yassine_dev1/"&gt;Instagram&lt;/a&gt; for more Content about Flutter❤ &lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
    </item>
    <item>
      <title>The ultimate collection of vscode extensions for flutter.</title>
      <dc:creator>Yassine BENNKHAY</dc:creator>
      <pubDate>Mon, 19 Apr 2021 17:38:47 +0000</pubDate>
      <link>https://dev.to/yassine_dev/the-ultimate-collection-of-vscode-extensions-for-flutter-56a8</link>
      <guid>https://dev.to/yassine_dev/the-ultimate-collection-of-vscode-extensions-for-flutter-56a8</guid>
      <description>&lt;p&gt;Flutter has been gained big popularity in the last few years, and today I'm going to show you the must-have Vscode Extensions to work comfortably with it and to multiply your productivity, so without any further words let go into it! &lt;/p&gt;

&lt;p&gt;1-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter"&gt;Flutter &lt;/a&gt; :&lt;/strong&gt;&lt;br&gt;
This VS Code extension adds support for effectively editing, refactoring, running, and reloading Flutter mobile apps, as well as support for the Dart programming language.&lt;/p&gt;

&lt;p&gt;2-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code"&gt;Dart&lt;/a&gt; :&lt;/strong&gt;&lt;br&gt;
Dart Code extends VS Code with support for the Dart programming language and provides tools for effectively editing, refactoring, running, and reloading Flutter mobile apps, and  &lt;a href="https://github.com/angulardart/angular"&gt;AngularDart&lt;/a&gt; web apps.&lt;/p&gt;

&lt;p&gt;3-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments"&gt;Better Comments&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
Better Comments&lt;br&gt;
The Better Comments extension will help you create more human-friendly comments in your code.&lt;br&gt;
With this extension, you will be able to categorize your annotations into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Alerts&lt;/li&gt;
&lt;li&gt;Queries&lt;/li&gt;
&lt;li&gt;TODOs&lt;/li&gt;
&lt;li&gt;Highlights&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Commented out code can also be styled to make it clear the code shouldn't be there&lt;br&gt;
Any other comment styles you'd like can be specified in the settings.&lt;/p&gt;

&lt;p&gt;4-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2"&gt;Bracket Pair Colorizer 2&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
This extension allows matching brackets to be identified with colors. The user can define which tokens to match, and which colors to use&lt;/p&gt;

&lt;p&gt;5-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=BendixMa.dart-data-class-generator"&gt;Dart Data Class Generator&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
Create dart data classes easily, fast, and without writing boilerplate or running code generation.&lt;/p&gt;

&lt;p&gt;6- &lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=naco-siren.gradle-language"&gt;Gradle Language Support&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
An extension to provide Gradle language support for Visual Studio Code, including advanced functionalities like Syntax Highlighting, Keyword Auto-completion Proposals, and Duplication Validation.&lt;/p&gt;

&lt;p&gt;7-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme"&gt;Material Icon Theme&lt;/a&gt;:&lt;/strong&gt; an extension to get the Material Design icons into your VS Code.&lt;/p&gt;

&lt;p&gt;8-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=jeroen-meijer.pubspec-assist"&gt;Pubspec Assist&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
Pubspec Assist is a Visual Studio Code extension that allows you to easily add dependencies to your Dart and Flutter project's pubspec.yaml, all without leaving your editor.&lt;/p&gt;

&lt;p&gt;9-&lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=Nash.awesome-flutter-snippets"&gt;Awesome Flutter Snippets&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development by eliminating most of the boilerplate code associated with creating a widget&lt;/p&gt;

&lt;p&gt;10- &lt;strong&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens"&gt;Error Lens&lt;/a&gt;:&lt;/strong&gt;&lt;br&gt;
ErrorLens turbo-charges language diagnostic features by making diagnostics stand out more prominently, highlighting the entire line wherever a diagnostic is generated by the language and also prints the message inline.&lt;/p&gt;

&lt;p&gt;Did I miss any extensions? Let me know in the comments.&lt;br&gt;
If you find this useful give it a like and don't forget to follow me on  &lt;a href="https://www.instagram.com/yassine_dev1/"&gt;Instagram&lt;/a&gt; and on my  &lt;a href="https://yassine-bennkhay.tech/"&gt;Blog&lt;/a&gt; for more useful stuff about flutter.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
