<?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: Patrick</title>
    <description>The latest articles on DEV Community by Patrick (@mod5ied).</description>
    <link>https://dev.to/mod5ied</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%2F425262%2F058e2130-27ed-4aa3-9893-123442fdc090.jpg</url>
      <title>DEV Community: Patrick</title>
      <link>https://dev.to/mod5ied</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mod5ied"/>
    <language>en</language>
    <item>
      <title>HOW TO SEARCH FOR FILES WITH USER-INPUT (Node.js)</title>
      <dc:creator>Patrick</dc:creator>
      <pubDate>Tue, 01 Feb 2022 00:39:25 +0000</pubDate>
      <link>https://dev.to/mod5ied/how-to-search-for-files-with-user-input-nodejs-4c19</link>
      <guid>https://dev.to/mod5ied/how-to-search-for-files-with-user-input-nodejs-4c19</guid>
      <description>&lt;p&gt;&lt;strong&gt;Node.js is an event-driven, JavaScript runtime which can&lt;br&gt;
perform operations asynchronously in a such a way that is non-blocking in execution sense. These operations could include: FS/IO, HTTP operations etc. Node wraps the JavaScript language with extra rich features which enables the language perform operations that it can't do by default such as: reading and writing to files locally, running a full-fledged end-to-end network communication; as JavaScript's scope of operation is limited to the browser window. Hence, Node can allow us run JavaScript in environments other than the restricting interface of the browser.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article we will see &lt;strong&gt;how to search for existing files&lt;/strong&gt; within a local directory via user-input in Node. At the end of this article, you should be familiar with the node and its&lt;br&gt;&lt;br&gt;
&lt;code&gt;fs&lt;/code&gt; and &lt;code&gt;readline&lt;/code&gt; modules and how to use its associated methods to find existing files in our directory.&lt;/p&gt;
&lt;h3&gt;
  
  
  Setup:
&lt;/h3&gt;

&lt;p&gt;First off, we auto create a &lt;code&gt;package.json&lt;/code&gt; file that will help us manage our dependencies and other things such as versioning in the future. &lt;br&gt;
So on your terminallocked in on the root of the project directory, type the code: &lt;br&gt;
&lt;code&gt;npm init –y&lt;/code&gt; or &lt;code&gt;yarn init -y&lt;/code&gt;&lt;br&gt;
This generates the package file. So, we can now install npm packages such as &lt;strong&gt;nodemon&lt;/strong&gt; which refreshes our node sessions each time we make and save a change to our files. &lt;br&gt;
Finally, we would update the &lt;strong&gt;package.json&lt;/strong&gt; file by adding a &lt;code&gt;type: "module"&lt;/code&gt; field to the file. This would enable us use the more modern and elegant ES2015(ES6) syntax in our node project(&lt;em&gt;this is optional, as you could choose to use commonjs &lt;code&gt;require&lt;/code&gt; syntax&lt;/em&gt;). Exciting huh ?&lt;br&gt;
Finally, we create an index.js file where we will write and test all our code.&lt;/p&gt;

&lt;p&gt;To serve as our dummy files to be read, we would create a folder called &lt;strong&gt;blogs&lt;/strong&gt; in our projects directory, there we will create three(3) text files - (&lt;em&gt;text1.txt, text2.txt, text3.txt&lt;/em&gt;), and for each of these files we populate them with our preferred dummy data- &lt;code&gt;Lorem Ipsum!&lt;/code&gt;&lt;br&gt;
You could also use a more meaningful data for this, its your choice. Your folder structure, and &lt;code&gt;package.json&lt;/code&gt; file should be looking similar to mine below:&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%2Fmazih3muy2yejikr1fl1.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%2Fmazih3muy2yejikr1fl1.png" alt="package.json"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Nodescratch",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
  "start": "nodemon index.js"
},
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "2.0.2"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Ok, back to Node:
&lt;/h3&gt;

&lt;p&gt;Nodejs has a couple of built-in core modules that can be used for various important operations, these includes: &lt;strong&gt;HTTP&lt;/strong&gt;, &lt;strong&gt;Events&lt;/strong&gt;, &lt;strong&gt;FS&lt;/strong&gt;, etc. We would be working with the FS module (&lt;em&gt;FS stands for File System; quite self-explanatory if you ask me&lt;/em&gt; ).&lt;br&gt;
The FS module has some important helper methods that we can use to make manipulations on both local files on our machine and &lt;em&gt;beyond&lt;/em&gt;. For this article, we would import and use three of these methods &lt;code&gt;readFile&lt;/code&gt;, &lt;code&gt;readdir&lt;/code&gt;, also we would import another&lt;br&gt;
method from the &lt;strong&gt;readline&lt;/strong&gt; module called &lt;code&gt;readline&lt;/code&gt;. This module allows us to read/accept data from the user via an interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import readline from "readline";
import { readFile, readdir } from "fs";
const { log, error } = await import('console') /* this is to avoid typing console.log or console.error redundantly */

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

&lt;/div&gt;



&lt;p&gt;To get users input, we would be using the &lt;code&gt;readline&lt;/code&gt; method which provides an interface for reading data from a readable stream, the most common being –&lt;br&gt;
&lt;code&gt;process.stdin&lt;/code&gt;. &lt;br&gt;
This operation takes some time to complete and hence traditionally&lt;br&gt;
we would often use a callback function to handle the response once it’s done, but we would be making our codes more Promise-based by using the &lt;code&gt;promisify&lt;/code&gt; method of nodes &lt;em&gt;community module&lt;/em&gt; called &lt;code&gt;util&lt;/code&gt; (&lt;em&gt;I would definitely talk about that in depth in another article&lt;/em&gt;). So, lets how that is used in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import readline from "readline";
import { readFile, readdir } from "fs";
const { log, error } = await import('console')

import util from "util";
const rFile = util.promisify(readFile);
const rDir = util.promisify(readdir);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;readFile&lt;/code&gt; asynchronously reads the entire contents of any file. This method takes two arguments, the relative path to the file and a callback function to handle response. But we would be using a rather modern approach by transforming this method to Promise-based method like the one above using &lt;code&gt;promisify&lt;/code&gt;.&lt;br&gt;
Inclusively, the &lt;code&gt;readdir&lt;/code&gt; method can read the contents of a directory (folder) and just like the &lt;code&gt;readFile&lt;/code&gt; method, &lt;code&gt;readdir&lt;/code&gt; takes two arguments: a relative path to the&lt;br&gt;
directory and a callback. Just like before, we would &lt;code&gt;promisify&lt;/code&gt; this method.&lt;br&gt;
Doing this enables us to elegantly use these methods with the &lt;code&gt;await&lt;/code&gt; keyword in an &lt;code&gt;async&lt;/code&gt; function as depicted below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import readline from "readline";
import { readFile, readdir } from "fs";
const { log, error } = await import('console')
import util from "util";

const rFile = util.promisify(readFile);
const rDir = util.promisify(readdir);
async function get() {
    try {
        const file = await rDir("./blogs");
        setTimeout(() =&amp;gt; log("Available files are:",file),3000);
    } catch (e) { error(e.message);}
}

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

&lt;/div&gt;



&lt;p&gt;Another function we would define is the search function which would listen to our inputs, formats its and make search operations asynchronously based on this input.&lt;br&gt;
But before we define this function, we need to create an interface that would let us key in inputs and also get outputs logged to the console. This function would be called later when we define an interface for accepting user input. Lets look at how the function is defined:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function search(userInput) {
  try {
    const data = await rFile(`${userInput}`);
    log(data.toString());
  } catch (e) {
    error(e.message);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we should note that the &lt;code&gt;question&lt;/code&gt; method of the &lt;code&gt;readline&lt;/code&gt; can be used to throw a query or question a user to perform an input operation. It should also have a callback function that grabs the input and runs an operation using the input as a payload; thus when called, &lt;code&gt;rl.question()&lt;/code&gt; will resume the input stream if it has been paused.&lt;br&gt;
Note, the callback passed to &lt;code&gt;rl.question&lt;/code&gt; does not follow the typical pattern of accepting an ‘&lt;em&gt;err &amp;amp; data&lt;/em&gt;’ as arguments, rather it’s called with the provided answer (&lt;em&gt;user-input&lt;/em&gt;) as the only argument. Lets see how that’s done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
rl.question("Search for a file..\n", (input) =&amp;gt; {
  const userInput = input.trim();
  search(userInput); // the 'search function is called at this point
  get(); // the 'get function is called after the search
  log(`You searched for ${userInput}`);
  rl.close();
});
rl.on("close", () =&amp;gt; {
  log("Searching....");
});

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

&lt;/div&gt;



&lt;p&gt;To execute this file and get our data using our input, open the Terminal, using the node runtime we would execute the module by typing - &lt;code&gt;node index.js&lt;/code&gt;. &lt;br&gt;
We would get a prompt that tells us to &lt;code&gt;Search for a file…&lt;/code&gt;.&lt;br&gt;
Enter the keywords - &lt;code&gt;blogs/text1.txt&lt;/code&gt;, which is the name of the dummy files we created earlier (&lt;em&gt;Don’t forget to include the .txt extension&lt;/em&gt;).&lt;br&gt;
And we should get a satisfactory result of -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You searched for blogs/text1.txt
Searching....
// data is output after some secs.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a moment you should get your file served to you beautifully on the Terminal, hurray.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary:
&lt;/h3&gt;

&lt;p&gt;Now, let’s have a summary of everything we’ve done so far. All we did was use a fancy syntax to get our users input via the &lt;code&gt;readline&lt;/code&gt; interface. A function is executed that uses the &lt;code&gt;readFile&lt;/code&gt; and &lt;code&gt;readdir&lt;/code&gt; method to search for and beautifully return our files content on the Terminal.&lt;/p&gt;

&lt;p&gt;If you made it to the end of this article, Congrats! Now you have a task of making this even more better and elegant than I could.&lt;br&gt;
Keep learning, keep discovering and keep sharing.&lt;/p&gt;

&lt;p&gt;Ping my Twitter handle when you can- &lt;a href="//www.twitter.com/mod5ied"&gt;Patrick&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>node</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Beginners Introduction to Response Handling (pt2)</title>
      <dc:creator>Patrick</dc:creator>
      <pubDate>Fri, 24 Dec 2021 22:05:39 +0000</pubDate>
      <link>https://dev.to/mod5ied/beginners-introduction-to-response-handling-pt2-504a</link>
      <guid>https://dev.to/mod5ied/beginners-introduction-to-response-handling-pt2-504a</guid>
      <description>&lt;p&gt;In the &lt;em&gt;&lt;a href="https://dev.to/mod5ied/a-beginners-introduction-to-making-api-requests-unsplash-api-2lfk"&gt;previous article&lt;/a&gt;&lt;/em&gt;, we talked at length about how to make a request to a server, and also about the structure of requests, but in this article we will be diving deep into &lt;strong&gt;HTTP response&lt;/strong&gt; as it relates to requests. &lt;br&gt;
An HTTP response is basically made by a server to a client reacting to a request. Its aim is to provide a resource back to the client (browser) that requested the file, or to inform the client about an error which occurred while processing the request; An error you might ask, yes and it’s worth noting that bad or invalid requests most often leads to an error as a response. It is a two-way process: a server can only give a response when it gets a request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--adOGwBNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fgt69n0s1xb8svxb6ic.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--adOGwBNF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fgt69n0s1xb8svxb6ic.jpg" alt="status-code" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An important technical concept to understand to be able to grasp what response are all about, and that is ‘&lt;strong&gt;HTTP status codes&lt;/strong&gt;’. “&lt;em&gt;Oh, another technical jargon!&lt;/em&gt;”, one thing you have to understand is that, the server issues an HTTP status code in response to a client’s request. In simpler terms, a user makes a request for a resource, the web server processes that request and if the resource is found or present, the server responds with a status code befitting that operation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYwyk9cX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8eyy1hv98fg2yjv4gk3n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYwyk9cX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8eyy1hv98fg2yjv4gk3n.jpg" alt="box-tag" width="880" height="1320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A response can be likened to a box that has a bold tag on it to give a quick and brief peek into what’s actually inside, it could be money who knows right? Similarly, an HTTP response is the Box, an HTTP status is the bold tag on the box (the box is the actual resource returned by a server to a client). That was a bit better and refreshing right?&lt;br&gt;
Now to understand this Box (response) properly let’s look at each individual parts separately, starting with the bold tag (HTTP status code) that gives a brief peek. HTTP status codes comes in forms of 3-digits and split into identity 5 categories: &lt;code&gt;(1xx, e.g. 101, 102)&lt;/code&gt;, &lt;code&gt;(2xx, e.g. 200, 202)&lt;/code&gt;, &lt;code&gt;(3xx, e.g. 300, 305)&lt;/code&gt;, &lt;code&gt;(4xx, e.g. 400, 404)&lt;/code&gt; and &lt;code&gt;(5xx, e.g. 501, 503)&lt;/code&gt;.&lt;br&gt;
The first category &lt;code&gt;(1xx)&lt;/code&gt; is an &lt;em&gt;information response&lt;/em&gt;, the second &lt;code&gt;(2xx)&lt;/code&gt; denotes &lt;em&gt;success&lt;/em&gt;, &lt;code&gt;(3xx)&lt;/code&gt; flags a &lt;em&gt;redirection&lt;/em&gt; – most commonly used to state that a resource has been moved from its original state. The fourth &lt;code&gt;(4xx)&lt;/code&gt; you may have seen while surfing the web – a &lt;code&gt;404&lt;/code&gt; error, that states that a resource was not found. Finally, &lt;code&gt;(5xx)&lt;/code&gt; occurs when there is a &lt;em&gt;server error&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Understanding the nature of these status codes helps a developer to know what to expect and also the next line of action should they appear. Hence, HTTP status code are a vital and integral part of a HTTP response that shouldn’t be overlooked. Next, we would now explore the fun part of the box (response), the goodies!! The content of a response can be in any of a number of format. They all span under a common type – MIME which is a Media type. This can specify the format of the data as a type/subtype e.g. &lt;code&gt;text/html&lt;/code&gt;, &lt;code&gt;text/xml&lt;/code&gt;, &lt;code&gt;application/json&lt;/code&gt; or &lt;code&gt;image/jpg&lt;/code&gt; etc.&lt;br&gt;
The response can be in any of the types – &lt;strong&gt;JSON&lt;/strong&gt;, &lt;strong&gt;XML&lt;/strong&gt;, &lt;strong&gt;BSON&lt;/strong&gt;, etc. and can be converted to any of these during the GET action or can be done after the response has been returned from the API. &lt;br&gt;
In the next article, we would be talking about the concept of &lt;em&gt;Content-Type headers&lt;/em&gt; and how important they are in handling data response gotten from a server. Keep in touch!&lt;br&gt;
Come on guys like and follow this dude to keep getting quality contents like this.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Beginners Introduction to Making API Requests (Unsplash API)</title>
      <dc:creator>Patrick</dc:creator>
      <pubDate>Tue, 21 Dec 2021 22:01:30 +0000</pubDate>
      <link>https://dev.to/mod5ied/a-beginners-introduction-to-making-api-requests-unsplash-api-2lfk</link>
      <guid>https://dev.to/mod5ied/a-beginners-introduction-to-making-api-requests-unsplash-api-2lfk</guid>
      <description>&lt;p&gt;So if you’ve followed upon the previous post where we discussed about Response, then this article about how to implement request and handle response with the &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; API would prove very useful in understanding the two concepts. This article by the way assumes you have a basic knowledge of JavaScript and its core concepts such as: Functions and the JavaScript fetch API. But if you don’t know, just read on, I’ll try to explain the steps as much as possible&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%2Fxjiav1nblw0dh3h3td1u.jpg" 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%2Fxjiav1nblw0dh3h3td1u.jpg" alt="requests"&gt;&lt;/a&gt;&lt;br&gt;
Now, to make a request in JavaScript, we have a lot of options, we could do an &lt;strong&gt;XHR&lt;/strong&gt; request, or we could use a package called &lt;strong&gt;&lt;em&gt;Axios&lt;/em&gt;&lt;/strong&gt; to make a Promise-based request to a web server if you working with a node-generated project. But for the sake of simplicity in this article, we would be using the JavaScript &lt;code&gt;fetch&lt;/code&gt; API. The Fetch API basically allows us to make HTTP requests to web servers. We could use Fetch on its own to make a request to our API and then tackle on the response using a &lt;code&gt;.then()&lt;/code&gt; function, or we could use a cleaner method of wrapping our Fetch in an &lt;code&gt;async&lt;/code&gt; function. Nevertheless, this article is not focused on teaching you how to write &lt;code&gt;async&lt;/code&gt; functions, rather how to use it to make our requests easier with Fetch.&lt;/p&gt;

&lt;p&gt;Having talked at length about making requests to an &lt;strong&gt;API&lt;/strong&gt; using Fetch, you may wonder what an API exactly is: In short an API (Application Programming Interface) is any standard interface or endpoint that facilitates connection to a web server. In this article we would be making a simple request to &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt; API. Unsplash is a web platform that acts as a repository of high quality free images, hence, their API enables us to make requests to their central server for an image, which would in turn make a response to us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Making a Request:&lt;/strong&gt;&lt;br&gt;
To get started, quickly scaffold a simple index.html project on your PC. It should look something similar to this:&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%2Fhzogmg3pttxj5wto2whs.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%2Fhzogmg3pttxj5wto2whs.png" alt="scaffold image"&gt;&lt;/a&gt;&lt;br&gt;
So at the script section of our project we are going to create two things: a fetch request without the async function as a wrapper and also a fetch request with the wrapper. This way we can get a knowledge of both worlds:&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%2F2wdsc0hi4v43a1oxc34j.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%2F2wdsc0hi4v43a1oxc34j.png" alt="requests"&gt;&lt;/a&gt;&lt;br&gt;
Now looking closely, the &lt;em&gt;searchTerm&lt;/em&gt; and the &lt;em&gt;accessKeys&lt;/em&gt; are two variables that would help our API below them function optimally. &lt;strong&gt;Access Keys are private hence endeavor to keep them hidden!&lt;/strong&gt;&lt;br&gt;
In fetch without async wrapper above, we use the fetch to make a GET request to a server(Unsplash) via an API, this request is then tackled on using the &lt;code&gt;.then()&lt;/code&gt; methods. The first one parses the response gotten from the server (res), converting it to a more usable “JSON” format; This enables us to access the response the same way we would with a JavaScript objects. Also, the second &lt;code&gt;.then()&lt;/code&gt; method grabs the parsed data and outputs it on our browsers console.&lt;br&gt;
The &lt;code&gt;async&lt;/code&gt; function too also helps in making asynchronous requests, how so: a response is expected and upon getting the response the data is stored in a constant called – res. Next we await the response to be parsed into a &lt;strong&gt;JSON&lt;/strong&gt; format, after resolving it is passed to a constant – data.&lt;br&gt;
One thing to note is that these operations occur in a non-blocking manner, they execute sequentially such that the fetch must run/execute and get a response before the response is then parsed, after which we then output or use the parsed data. Such is the nature of asynchronous JavaScript.&lt;br&gt;
If you’ve followed this article properly, you should come to the understanding of not the syntax for making a GET request to an API using fetch, but rather of how making requests asynchronously works in JavaScript. Handling Responses and using them on our page is also vital to understand. &lt;em&gt;The part2&lt;/em&gt; of this article series would explain not only how to handle and use responses but also how to structure our requests to catch and handle errors too, should they occur. Happy Learning!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Requests and Response for Beginners</title>
      <dc:creator>Patrick</dc:creator>
      <pubDate>Mon, 20 Dec 2021 22:28:03 +0000</pubDate>
      <link>https://dev.to/mod5ied/request-and-response-for-beginners-450h</link>
      <guid>https://dev.to/mod5ied/request-and-response-for-beginners-450h</guid>
      <description>&lt;p&gt;Have you asked the waiter at a restaurant to get you a dessert and they served you exactly what you wanted? Have you also asked for a Chicken-soup but got Chips instead? Well, believe it or not this is very similar to making requests and receiving responses on the web.&lt;br&gt;
From the previous article we understood that we can make requests to a server via a link or a portal commonly called an &lt;strong&gt;endpoint&lt;/strong&gt; or an &lt;strong&gt;API&lt;/strong&gt;; the server processes this request that we have made prepares a response accordingly and passes it back to us via the endpoint, hence we can work with the response as we please.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mT4gr9Iw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3w24w82m543q0ll1mjc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mT4gr9Iw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z3w24w82m543q0ll1mjc.jpg" alt="request" width="880" height="1320"&gt;&lt;/a&gt; &lt;br&gt;
A request could be of a number of type, we have the &lt;strong&gt;GET&lt;/strong&gt; request: this is one of the most common forms of request programmers and developers alike often use to get a resource from a server. Another type of request is the &lt;strong&gt;POST&lt;/strong&gt; request: this is a type of request that’s most commonly used in connotation to submitting a resource or a data to the server. It instructs the server to accept and store a data from the user/sender. We have other types of requests such as “&lt;strong&gt;PUT&lt;/strong&gt;, &lt;strong&gt;DELETE&lt;/strong&gt;, &lt;strong&gt;PATCH&lt;/strong&gt;, &lt;strong&gt;HEAD&lt;/strong&gt;, &lt;strong&gt;CONNECT&lt;/strong&gt;”. Note: all these can be more specifically termed – &lt;em&gt;http requests&lt;/em&gt;.&lt;br&gt;
A response on the other hand is gotten or received for the server in a number of formats, it could either be a blob, a &lt;strong&gt;JSON&lt;/strong&gt; (JavaScript Object Notation) data etc. Now to use this response, developers usually parse the response into other usable format (by default the browser returns a response in a format that is not readily usable), example the JSON format. It is always important to parse a response for the above reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zrns-2pe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1zh846kwcv6rotnic7b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zrns-2pe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1zh846kwcv6rotnic7b.jpg" alt="bad-request" width="880" height="685"&gt;&lt;/a&gt;&lt;br&gt;
Note that, valid requests to a server via its endpoint leads to a successful or complete response. When you make an invalid request, the server could flag it as a bad request and reject, throwing an http status code to further explain the nature of that request.&lt;/p&gt;

&lt;p&gt;Having understood what requests are, we can now see how it relates to responses and how the server reacts to this via its endpoint or API. This is an interesting way to understand the concept of request and response which are also one of the core foundations of web development we should all understand. More interesting articles like this are available.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>A Beginners Introduction to Web Development</title>
      <dc:creator>Patrick</dc:creator>
      <pubDate>Sun, 19 Dec 2021 20:53:56 +0000</pubDate>
      <link>https://dev.to/mod5ied/a-beginners-introduction-to-web-development-1lbb</link>
      <guid>https://dev.to/mod5ied/a-beginners-introduction-to-web-development-1lbb</guid>
      <description>&lt;h2&gt;
  
  
  What is Web Development?
&lt;/h2&gt;

&lt;p&gt;The development of pages of information stored across series of interconnected resource-hubs/machines that acts to serve information as at when needed has led to the advent of websites and web-apps alike. A website serves two major purpose- to serve relevant information as requested by a user, and or to accept data as input from a user to process: web platforms that performs that kind of operations are specifically referred to as web-apps.&lt;br&gt;
Now to understand how webpages work, let’s use a ‘Barman’s’ description: ‘you go to a bar (a web browser), greet the barman (server), request for a glass of beer (web address/request), and he pours us a glass of cool beer with a smile (webpage/response)’.&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%2Fsx1w6ntt044cieezm0h9.jpg" 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%2Fsx1w6ntt044cieezm0h9.jpg" alt="Barman"&gt;&lt;/a&gt;&lt;br&gt;
 From this analogy, we see that we get a web result known as a response when we make a valid request to a server. This is a simple but in exact terms how a websites or webpages are served.&lt;br&gt;
Web development as the name implies entails a series of steps taken to solve a given problem using a variety of web technologies. These web technologies enable a web developer to quickly scaffold a web platform that is performant and solves a task or series of tasks, example: Amazon which solves the problem of shopping and home-delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get started?
&lt;/h2&gt;

&lt;p&gt;Now for a beginner, it can get really confusing where to start as there are many resources claiming to be the best in making you a developer. First, let’s look at what to have in mind before beginning your journey:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A Capable Text-editor&lt;/strong&gt;: You don’t have to break the bank for this, there are a lot of free software to use out there to start with, such as &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VSCode&lt;/a&gt;, &lt;a href="https://atom.io/" rel="noopener noreferrer"&gt;Atom&lt;/a&gt;, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A web browser&lt;/strong&gt; (obviously, so you can see your work as you build it). Most PCs come with one pre-installed, so no fuss at that.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An online resource&lt;/strong&gt; to get you started with learning, now from my vast knowledge of resources out there, there are so many (free or paid) that opines to makes you better at developing the web, I rounded up two from each category of ‘Free’ and ‘Paid’.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For the free category, I strongly recommend &lt;a href="https://www.freecodecamp.org/" rel="noopener noreferrer"&gt;Freecodecamp&lt;/a&gt; for day-to-day studies as they have an awesome curriculum. Second, you should back up that knowledge using &lt;a href="https://www.w3schools.com/" rel="noopener noreferrer"&gt;w3schools website&lt;/a&gt; – this platform has a rich collection of docs that explains each web technology (HTML, CSS...) and its usage in depth. It is vital to use both in parallel in your studies to better understand each concept.&lt;/p&gt;

&lt;p&gt;Now for the paid category, &lt;a href="https://www.udemy.com/" rel="noopener noreferrer"&gt;Udemy&lt;/a&gt; has a great collection of video resources that are curated by authors who are experienced developers, and this can help you go a long way. Second, I think &lt;a href="https://www.pluralsight.com/" rel="noopener noreferrer"&gt;Pluralsight&lt;/a&gt; has an awesome collection of video resources by experts in the web industry, which cement the use of each technology into your mind. Whichever you choose from here solely depends on you and your learning preference.&lt;br&gt;
&lt;a href="https://www.youtube.com/" rel="noopener noreferrer"&gt;Youtube&lt;/a&gt; also has loads of free videos on practically every concept you could think of that concerns web development, hence is also worth checking out if you want a free video resource.&lt;/p&gt;

&lt;p&gt;A good video or text resource should carry you along, explaining concepts precisely and exactly the way it should with code snippets or samples backing up such explanations, not just having code snippets littered everywhere or just all talks and texts with no code/practice to explain or show.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do I get started?
&lt;/h2&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%2Fo3xmto87dwi3ersq8eus.jpg" 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%2Fo3xmto87dwi3ersq8eus.jpg" alt="coding"&gt;&lt;/a&gt;&lt;br&gt;
Finally, you should know that the journey to becoming a proficient web developer is tough. It is a life-long commitment to learning and working on various concepts that may shake your depths of understanding. But make sure to ground yourself with the basics as much as you possibly can before diving into advanced concepts.&lt;br&gt;
It can get really enjoyable when you attain basic or little proficiency, the joy of building what works is amazing, hence keep at it and do your best to grab the most important concept, don’t try to learn everything all at once, structure your learning timetable and stick to it.&lt;br&gt;
Remember, &lt;strong&gt;&lt;em&gt;one step at a time&lt;/em&gt;&lt;/strong&gt;, then you might attain advanced proficiency after all.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
