<?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>Forem: Kelvin Sowah</title>
    <description>The latest articles on Forem by Kelvin Sowah (@ksowah).</description>
    <link>https://forem.com/ksowah</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%2F907338%2F8a5bdb8c-abce-4340-81b3-434e6c17dd32.jpeg</url>
      <title>Forem: Kelvin Sowah</title>
      <link>https://forem.com/ksowah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ksowah"/>
    <language>en</language>
    <item>
      <title>How to Use Axios for HTTP Requests</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Thu, 12 Jan 2023 00:10:37 +0000</pubDate>
      <link>https://forem.com/ksowah/how-to-use-axios-for-http-requests-p1l</link>
      <guid>https://forem.com/ksowah/how-to-use-axios-for-http-requests-p1l</guid>
      <description>&lt;p&gt;Hello readers, and welcome to another blog post where I attempt to explain a technical concept used in the software development world. I make an effort to accomplish this by giving clear examples and demystifying a few ideas. This blog will primarily discuss Axios, my go-to &lt;code&gt;HTTP&lt;/code&gt; request tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Axios?&lt;/strong&gt;&lt;br&gt;
Simply put, Axios is a well-known JavaScript library that enables HTTP requests to GraphQL or RESTful APIs. Axios performs the same function as the fetch API. Promises are used in the background of Axios. Please click &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" rel="noopener noreferrer"&gt;here&lt;/a&gt; to get more information about Promises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements For Using Axios&lt;/strong&gt;&lt;br&gt;
You must first have Node.js installed on your PC before using Axios. Please click on this &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;link&lt;/a&gt; if you don't have Node.js installed . You can access the official Node.js website by clicking this link, which lists the instructions for installing Node.&lt;/p&gt;

&lt;p&gt;Axios must then be added to your project. Simply enter the following command in your terminal to achieve this (always ensure you are in the right directory):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following command will function for you if you're using yarn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using Axios&lt;/strong&gt;&lt;br&gt;
I like using Axios over the fetch API mostly because it offers a very clear and accurate syntax. Here is a case study to help you understand my point.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;making a get request with the &lt;code&gt;fetch&lt;/code&gt; API below&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fo8prtrgazmtxdizwolzn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fo8prtrgazmtxdizwolzn.png" alt="using the fetch api" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;making a get request with the &lt;code&gt;Axios&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1l05i67balzz7bs6qpu7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1l05i67balzz7bs6qpu7.png" alt="using the axios api" width="800" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above example, I'm using a &lt;code&gt;GET&lt;/code&gt; request to get an object containing a name and age from the &lt;code&gt;jsonkeeper api&lt;/code&gt;. With the help of the &lt;code&gt;fetch api&lt;/code&gt; in the first image and Axios in the second, this can be accomplished. To utilize Axios, we first call the &lt;code&gt;axios&lt;/code&gt; function, and then we call any of the Axios library's functions that correspond to the various &lt;code&gt;HTTP&lt;/code&gt; &lt;a href="https://www.restapitutorial.com/lessons/httpmethods.html" rel="noopener noreferrer"&gt;verbs&lt;/a&gt;. In the example above, we are obviously sending a &lt;code&gt;GET&lt;/code&gt; request using the &lt;code&gt;get()&lt;/code&gt; method. The code on line 3 in the second image will yield a Promise because Axios uses Promises.&lt;/p&gt;

&lt;p&gt;You immediately observed that the second image has one less &lt;code&gt;then()&lt;/code&gt; method than the first. This is because, in contrast to the &lt;code&gt;fetch api&lt;/code&gt;, Axios gives the data you want. The Axios library has a drawback in that it delivers an object that contains a key of data that corresponds to the data you were expecting. To obtain the object of name and age, we called res.data on line 4 of the second image.&lt;/p&gt;

&lt;p&gt;You might be asking why the quantity of code doesn't differ significantly. That is accurate for &lt;code&gt;GET&lt;/code&gt; requests, but you can start to appreciate the advantages of using Axios in the example that makes a &lt;code&gt;POST&lt;/code&gt; request in the next section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxlvzbzjj9j8i07ul9ba6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxlvzbzjj9j8i07ul9ba6.png" alt="using the fetch aoi" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjop4zcozfqyxwh3zbi6a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjop4zcozfqyxwh3zbi6a.png" alt="using the axios api" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The difference in code density is very noticeable, and the code is also more accurate. Axios &lt;code&gt;post()&lt;/code&gt; method requires a second argument during a &lt;code&gt;POST&lt;/code&gt; request, and it must be an object. In this instance, we are passing an object, the constant &lt;code&gt;student&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The remainder, stringifying our object and creating the headers, is then handled by Axios. These actions must be carried out manually when using the &lt;code&gt;fetch api&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hopefully this blog post have helped you better grasp how to use Axios to fetch data and persuaded you that it is a better option to the fetch api. Thank you for reading, and please give Axios a shot.&lt;/p&gt;

&lt;p&gt;Thank You for reading. If you find this blog to be helpful, please like, share, and leave your thoughts in the comment section as well.&lt;br&gt;
You can also follow me on &lt;a href="https://twitter.com/Ksowahh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Useful High Order Functions in JavaScript</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Fri, 23 Dec 2022 23:56:23 +0000</pubDate>
      <link>https://forem.com/ksowah/useful-high-order-functions-in-javascript-4dl4</link>
      <guid>https://forem.com/ksowah/useful-high-order-functions-in-javascript-4dl4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.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%2F3loxvitcc7z47336g3kw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F3loxvitcc7z47336g3kw.png" alt="js banner" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, high order functions are those that possess one or both of the following characteristics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;accepts as an argument another function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Returns another function&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thankfully, JavaScript has a lot of high order functions built right into the language. The most practical and widely utilized high order functions will be discussed next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;forEach()&lt;/strong&gt;&lt;br&gt;
Iterating over an array of elements and running a function on each one is what this built-in method of the language does. &lt;code&gt;ForEach()&lt;/code&gt; will get this function as an argument.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flm44g6a5af8nxgaymf4x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flm44g6a5af8nxgaymf4x.png" alt="foreach loop js" width="681" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the given example, an array of names was created and saved to the constant &lt;code&gt;names&lt;/code&gt;. The fact that this function only operates on arrays is crucial. Then, we used the array's &lt;code&gt;forEach()&lt;/code&gt; method, passing a callback function as a parameter. Every entry in the array must be taken and logged to the console by the callback function. The last four lines of code display that.&lt;/p&gt;

&lt;p&gt;Another example is shown below, however this time numbers are used, and each number is added by 5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F6a0xz0wjlibjzp1imm94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F6a0xz0wjlibjzp1imm94.png" alt="foreach loop with numbers" width="681" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;map()&lt;/strong&gt;&lt;br&gt;
This method iterates across an array of various elements and accepts a function as an argument, much like &lt;code&gt;forEach()&lt;/code&gt;. Then, each element of the array will receive an application of the function. The sole distinction between &lt;code&gt;forEach()&lt;/code&gt; and &lt;code&gt;map()&lt;/code&gt; is that &lt;code&gt;map()&lt;/code&gt; builds a fresh array. Although it might not appear important, the &lt;code&gt;map()&lt;/code&gt; method is widely used in React, a JavaScript library for generating user interfaces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fe4lxe8h4el7bybwxr2rv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fe4lxe8h4el7bybwxr2rv.png" alt="js map function" width="681" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once again, we created a new array of numbers. We made a new variable to hold the new array that &lt;code&gt;map()&lt;/code&gt; returns because it returns a new array. The two variables were then recorded.The new array produced by the &lt;code&gt;map()&lt;/code&gt; method is displayed in the console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;find()&lt;/strong&gt;&lt;br&gt;
The name of this function, however, does a great job of describing what it does. It basically identifies the first member in an array that satisfies the condition stated in the function (also known as a callback function), which it will take as an argument, in case you couldn't guess what it does. That element will be returned by the &lt;code&gt;find()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fdy7ed8ynnrkl0zesq9yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fdy7ed8ynnrkl0zesq9yb.png" alt="js find method" width="681" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same variable is used in the code above, but this time we iterate through the array using the &lt;code&gt;find()&lt;/code&gt; method. We included a condition in the callback function's code block. In other words, if the number is less than 20, send it back to me. The condition is to return the first integer for which the condition evaluates to true.&lt;/p&gt;

&lt;p&gt;If you need to find a specific item in an array, this function may be useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;filter()&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;filter()&lt;/code&gt; method is the next one on the list, and its role is to return a new array containing all the elements that satisfy the function's argument-passing condition. The &lt;code&gt;find()&lt;/code&gt; method and this one share some commonalities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fsn2lyifjysudgaja2r01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fsn2lyifjysudgaja2r01.png" alt="js filter function" width="681" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once again, using the same array of numbers, we applied the &lt;code&gt;filter()&lt;/code&gt; function to it, which will yield a new array with the elements for which the test was successful. The result is a completely new array that only contains the elements that met our criterion after we have logged our new constant &lt;code&gt;filteredNumbers&lt;/code&gt;. &lt;br&gt;
Bonus: React also frequently employs this strategy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;reduce()&lt;/strong&gt;&lt;br&gt;
Although it is not as frequently used as the earlier functions, I believe this one has its uses. If the elements are all of the &lt;code&gt;type number&lt;/code&gt;, you can use it to add them all together. An example would probably be more effective than my explanation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fzrjga6a9kguwjgheje43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fzrjga6a9kguwjgheje43.png" alt="JS reduce function" width="681" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We start out by declaring a variable that holds an array as usual. After that, we use the array's &lt;code&gt;reduce()&lt;/code&gt; method and pass a callback function to it. &lt;code&gt;Reduce()&lt;/code&gt; requires at least two arguments in the callback function, as opposed to the previous methods, which require at least one. The &lt;code&gt;add&lt;/code&gt;, the first argument, serves as a container for the collected value of each iteration. The &lt;code&gt;add&lt;/code&gt; begins out with a value of zero if nothing is specified.&lt;/p&gt;

&lt;p&gt;Each unique integer in the array is represented by the callback function's second argument (&lt;code&gt;number&lt;/code&gt;). Each element is added to the accumulator within the code block. Let me walk you through how the &lt;code&gt;reduce()&lt;/code&gt; function works.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;add&lt;/code&gt; has a value of 25 on the initial iteration (0 + 25).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;add&lt;/code&gt;'s starting value is 0.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The array's first element, represented by 25, is added to the &lt;code&gt;add&lt;/code&gt;, which now contains the value of 25.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The accumulator has a value of 45 (25 + 20) after the second iteration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;add&lt;/code&gt;'s current value, which comes from the first iteration, is 25.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The array's second element is 20.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;add&lt;/code&gt; is currently 45.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Up until there are no more elements in the array to iterate, this operation is repeated. Then &lt;code&gt;reduce()&lt;/code&gt; returns the &lt;code&gt;add&lt;/code&gt;'s most recent value.&lt;/p&gt;

&lt;p&gt;If you're interested in learning more about other high order functions that JavaScript includes by default, visit &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank You for reading. If you find this blog to be helpful, please like, share, and leave your thoughts in the comment section as well.&lt;br&gt;
You can also follow me on &lt;a href="https://twitter.com/Ksowahh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Useful VS Code Extensions</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Wed, 21 Dec 2022 20:46:23 +0000</pubDate>
      <link>https://forem.com/ksowah/useful-vs-code-extensions-336b</link>
      <guid>https://forem.com/ksowah/useful-vs-code-extensions-336b</guid>
      <description>&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%2Fa1r8kf8ppya17nlkbmz5.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%2Fa1r8kf8ppya17nlkbmz5.png" alt="vscode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any software engineer, developer, or programmer's code editor is one of their most essential tools. Numerous code editors are available, including Sublime Text, Atom, Notepad++, and Visual Studio Code. The fact that the majority of code editors, including the one listed above, are free and supported by major corporations like Microsoft and others is one of their many excellent advantages. This indicates that the code editors will be properly updated and maintained.&lt;/p&gt;

&lt;p&gt;In this blog, we'll concentrate on Visual Studio Code (VS Code), which is both one of the most popular code editors and a personal favorite of mine, per a recent survey conducted by the &lt;a href="https://insights.stackoverflow.com/survey/2018#development-environments-and-tools" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt; team. Code editors in general, but particularly VS Code, can increase programmers' productivity and relieve a ton of stress and aggravation. Please click &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt; to go to VS Code's official website if you're interested in utilizing it. You can choose to download a version that is compatible with the operating system of your computer, if that choice is available.&lt;/p&gt;

&lt;p&gt;Let's now discuss a few features and extensions that you can add to VS Code to increase your productivity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emmet&lt;/strong&gt;&lt;br&gt;
VS Code has a ton of cool features right out of the box. Emmet is one of those characteristics. While Emmet is a plugin that can be used with various code editors, VS Code already has it installed, so there is no need to manually install it. Emmet offers abbreviations that translate into whole HTML code. HTML is typically written using repeated syntax. See the excellent use case for emmet below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;(header&amp;gt;ul&amp;gt;li*2&amp;gt;a)+footer&amp;gt;p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code shown above expands to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;
    &amp;lt;header&amp;gt;
        &amp;lt;ul&amp;gt;
            &amp;lt;li&amp;gt;&amp;lt;a href=""&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
            &amp;lt;li&amp;gt;&amp;lt;a href=""&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;/ul&amp;gt;
    &amp;lt;/header&amp;gt;
    &amp;lt;footer&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/footer&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, emmet can help you avoid doing repetitive tasks. Please click &lt;a href="https://emmet.io/" rel="noopener noreferrer"&gt;here&lt;/a&gt; to find out more about emmet acronyms.&lt;/p&gt;

&lt;p&gt;You must select the extensions tab (red arrow) in the activity bar in order to add extensions to Visual Studio Code. The illustration below may be of use.&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%2Fqelb4a4odmwk5bw4s99x.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%2Fqelb4a4odmwk5bw4s99x.jpg" alt="vscode extentions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the activity bar is not visible, please check that &lt;code&gt;Show Activity Bar&lt;/code&gt; is selected under &lt;code&gt;View → Appearance&lt;/code&gt;. You can enter the name of the extension you wish to add or install in the search box (green arrow) that appears when you access the extensions tab. You can use each extension's functionality according to the instructions provided with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bracket Pair Colorizer&lt;/strong&gt;&lt;br&gt;
The brackets and parenthesis in your code now have colors thanks to this plugin. This can make it much easier to determine which brackets are pairs when you have brackets and parentheses nested inside of other brackets and parentheses. Here is a fantastic illustration of how this extension functions.&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%2F6mf9ptlnj5k2go52ir3w.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%2F6mf9ptlnj5k2go52ir3w.png" alt="bracket pair colorization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Spell Checker&lt;/strong&gt;&lt;br&gt;
This plugin functions as a spell checker for your code editor, as the name would imply. The fact that this extension works well with &lt;a href="https://en.wikipedia.org/wiki/Camel_case" rel="noopener noreferrer"&gt;camelCase&lt;/a&gt; code is one of its best qualities. Additionally, you may make the spell checker compatible with various file types (Python, Javascript, Java, Go and many others).&lt;/p&gt;

&lt;p&gt;By preventing bugs from entering your code, this extension can spare you untold hours of frustration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ES7 React/Redux/GraphQL/React-Native snippets&lt;/strong&gt;&lt;br&gt;
Given that it offers incredible shortcuts for developing class or functional components, this plugin is ideal for React and React Native developers. This plugin can be compared to emmet, but for the React environment. An extensive list of the shortcuts offered is provided on the official &lt;a href="https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets" rel="noopener noreferrer"&gt;website&lt;/a&gt; for this extension.&lt;/p&gt;

&lt;p&gt;As I said, this plugin can save you a ton of time by producing components really quickly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live Server&lt;/strong&gt;&lt;br&gt;
This plugin is one of the most practical and helpful ones I've ever used, in my view. This extension builds a local development server with live page reload functionality for both static and dynamic pages. When you are mostly working with HTML and CSS files, this is really helpful (no framework involved). Once your files are saved, it reflects whatever modifications you've made to them. This kind of capability is often present when using a framework.&lt;/p&gt;

&lt;p&gt;If the extension is already installed, all you need to do to use it is right-click the file you want to open and select Open with Live Server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prettier — Code formatter&lt;/strong&gt;&lt;br&gt;
This extension's goal is to assist you in formatting your code to improve readability. Every time you save a file, this extension is activated, and it almost supports all file types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript (ES6) code snippets&lt;/strong&gt;&lt;br&gt;
Excellent Javascript code snippets are offered by this extension. Similar to earlier extensions, this one aims to reduce repetitions by offering shortcuts to some of the most popular Javascript code. The extension is compatible with Typescript, HTML, JSX, and Vue files.&lt;/p&gt;

&lt;p&gt;As a developer, I have utilized a few of these extensions. Please feel free to investigate and test out additional extensions since there are many more that are very useful but were not discussed in this blog.&lt;/p&gt;

&lt;p&gt;Thank you for reading; I hope my blog is useful to you in your efforts to become a more effective developer.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>vscode</category>
    </item>
    <item>
      <title>How To Use LocalStorage</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Tue, 20 Dec 2022 20:25:49 +0000</pubDate>
      <link>https://forem.com/ksowah/how-to-use-localstorage-il0</link>
      <guid>https://forem.com/ksowah/how-to-use-localstorage-il0</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.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%2Fxkrhzdhpccq315nxvz2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxkrhzdhpccq315nxvz2z.png" alt="javascript banner" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Welcome again, reader, to another entry in my blog where I attempt to demystify and explain a technical topic. I'm going to concentrate on &lt;code&gt;localStorage&lt;/code&gt; this time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is LocalStorage?&lt;/strong&gt;&lt;br&gt;
In the simplest terms, &lt;code&gt;localStorage&lt;/code&gt; is a feature of the browser that enables us to save data inside the browser. With one very significant exception, it functions quite similarly to &lt;code&gt;sessionStorage&lt;/code&gt;. Even when you exit the browser window, data stored in &lt;code&gt;localStorage&lt;/code&gt; will continue to exist in the browser. The information kept in &lt;code&gt;sessionStorage&lt;/code&gt;, on the other hand, will be erased when the user closes the browser window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What kind of data can be kept in localStorage?&lt;/strong&gt;&lt;br&gt;
Key-value pairs are used to store data in &lt;code&gt;localStorage&lt;/code&gt;. I want to make one very crucial point: &lt;code&gt;localStorage&lt;/code&gt; can only be used to store strings. An object from an array will be automatically transformed into a string if you attempt to store it. Use the &lt;code&gt;JSON.parse()&lt;/code&gt; method if you want to change the string back to its original data type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we communicate with localStorage?&lt;/strong&gt;&lt;br&gt;
We can interact with localStorage using a number of inbuilt ways. The capabilities of each of these techniques are listed in detail below.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;localStorage.setItem()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Two arguments are expected by this method. Both the first and the second are pieces of information you want to store. Since &lt;code&gt;localStorage&lt;/code&gt; may only hold strings, both arguments must be strings. I've provided an example below to assist you understand my perspective.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localStorage.setItem("name", "Kelvin Sowah")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The name key and its value are essentially stored in &lt;code&gt;localStorage&lt;/code&gt; by the code above.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;localStorage.getItem()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This method's objective is to fetch data from &lt;code&gt;localStorage&lt;/code&gt;. The key of the value you wish to obtain from &lt;code&gt;localStorage&lt;/code&gt; is the only input this function expects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;localStorage.getItem("name")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value corresponding to the key of &lt;code&gt;name&lt;/code&gt; will be returned by the code example above. It will return &lt;code&gt;"Kelvin Sowah"&lt;/code&gt; in our case.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;localStorage.removeItem()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The method's name implies that you can use it to delete a single set of key-value pairs from &lt;code&gt;localStorage&lt;/code&gt;. One parameter, which might be any of the keys in &lt;code&gt;localStorage&lt;/code&gt;, is required by the method.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;localStorage.removeItem("name")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, there shouldn't be any data with the key &lt;code&gt;name&lt;/code&gt; in our &lt;code&gt;localStorage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;localStorage.clear()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In contrast to the previous method, this one completely clears the &lt;code&gt;localStorage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I appreciate you reading my brief but enlightening blog. Hopefully, you now have a clearer idea of what &lt;code&gt;localStorage&lt;/code&gt; is and know how to use it.&lt;/p&gt;

</description>
      <category>pwa</category>
      <category>mobile</category>
    </item>
    <item>
      <title>How To Use Async/Await</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Mon, 19 Dec 2022 21:59:05 +0000</pubDate>
      <link>https://forem.com/ksowah/how-to-use-asyncawait-1egb</link>
      <guid>https://forem.com/ksowah/how-to-use-asyncawait-1egb</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.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%2Funij93pzku3449vglidj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Funij93pzku3449vglidj.jpg" alt="a javascript banner" width="800" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Welcome again readers to another blog post where I attempt to demystify and explain a technical topic. What async/await is and how to utilize it will be the main topics of this blog.&lt;/p&gt;

&lt;p&gt;I believe it would be wise to take a step back and briefly explore how JavaScript operates before I explain what async/await is. As you may be aware, JavaScript executes your code synchronously, which means that it can only execute one line of code at a time and must wait for that line of code to finish before executing the next. This might cause some issues.&lt;/p&gt;

&lt;p&gt;Synchronous JavaScript code has the potential to stall execution once it has begun doing something when it is run. To put it another way, long-running JavaScript functions can cause the user interface (UI) or server to become unusable until the function returns. This obviously has the potential to ruin the user experience.&lt;/p&gt;

&lt;p&gt;For instance, if your code runs synchronously and your web page or application requests a list of posts from a server, it may cease working until you can retrieve the articles. Depending on your connection, this may take some time, during which time your user is unable to engage with your application.&lt;/p&gt;

&lt;p&gt;Due to the utilization of Web APIs, we are able to run asynchronous JavaScript code to address this problem. The fetch api is one of the most used Web APIs for asynchronous programs. By returning a Promise, the fetch api enables you to execute asynchronous function. A Promise, put simply, is an object that signifies the success or failure of an asynchronous operation.&lt;/p&gt;

&lt;p&gt;Here is a code sample that uses the fetch api:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ft83ervf3tcyatu3l757o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ft83ervf3tcyatu3l757o.png" alt="sample code for the js fetch api" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A request is sent to the jsonkeeper api in the code above. an array of an object containing my name and age will be returned. In line 2 of the code, an &lt;code&gt;HTTP&lt;/code&gt; request is made using the &lt;code&gt;fetch&lt;/code&gt; api, which will eventually return a promise. Following the code in the first &lt;code&gt;then()&lt;/code&gt; function (line 3) if the promise is successful, we will go on to the second &lt;code&gt;then()&lt;/code&gt; method (line 4). Any time a promise is rejected or unsuccessful, our code will immediately move to the &lt;code&gt;catch()&lt;/code&gt; method (line 7), where it will log the error to the console in this example. Although using the &lt;code&gt;catch()&lt;/code&gt; method is not required, I strongly advise it because it enables you to give feedback to your user on the occurrence of an error.&lt;/p&gt;

&lt;p&gt;I should eventually explain what async/await is after going down that rabbit hole—trust me, it goes much deeper. In essence, the new JavaScript feature Async/Await allows you to create asynchronous code in a synchronous manner. The code example I presented before, refactored to use async/await, is shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftp88wjy5ozoxxlbfe76g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftp88wjy5ozoxxlbfe76g.png" alt="sample code of async await" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's go through the code:&lt;/p&gt;

&lt;p&gt;In order to use async/await, you must first inform the JavaScript engine that this function will run some asynchronous code. The &lt;code&gt;async&lt;/code&gt; keyword is added before our function to achieve this (line 1).&lt;/p&gt;

&lt;p&gt;You must include a try/catch block in the async function code block if you intend to handle errors if the promise is rejected or unsuccessful (this is a must!). If the promises are fulfilled, the code in the try block will be executed; otherwise, we will leave the try block, enter the catch block, and run any relevant code there.&lt;/p&gt;

&lt;p&gt;The try block currently contains the most crucial code. There are various constants in there. The promise provided by our HTTP request is contained in the first constant &lt;code&gt;response&lt;/code&gt; (line 3), but in order for this to function, we must first add the &lt;code&gt;await&lt;/code&gt; keyword before our retrieve function. When you want a promise in return, you need to include the &lt;code&gt;await&lt;/code&gt; keyword. Using the &lt;code&gt;data&lt;/code&gt; constant, we carry out the identical procedure once more (line 4). Our &lt;code&gt;data&lt;/code&gt; constant, which in this case is an array of one object, includes the information we require at this point in the code execution.&lt;/p&gt;

&lt;p&gt;We can use our data however we'd like now that it's been saved in a constant.&lt;/p&gt;

&lt;p&gt;If you compare the two samples of code, you'll see that the async/await code is longer, especially when the try/catch statement is taken into account. However, utilizing async/await enables you to view the code in synchronous mode, which makes it easier for you to keep track of what is occurring in your code and what data is available at any given moment. Although the function I used as an example is extremely simple to comprehend, asynchronous code can become much more complicated than what I shown, and at that point, we can truly appreciate how powerful async/await is.&lt;/p&gt;

&lt;p&gt;I appreciate you taking the time to read this post, and I hope it has given you a better knowledge of async/await and how to use it.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Initialize A React Native And Expo CLI Project</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Sat, 17 Dec 2022 19:54:48 +0000</pubDate>
      <link>https://forem.com/ksowah/initialize-a-react-native-and-expo-cli-project-2gah</link>
      <guid>https://forem.com/ksowah/initialize-a-react-native-and-expo-cli-project-2gah</guid>
      <description>&lt;p&gt;Welcome back, readers, to another blog where I attempt to clarify a technical issue or aid you in your effort to improve as a developer. This post will be focused on using the Expo CLI to launch a React Native project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React Native?&lt;/strong&gt;&lt;br&gt;
The very popular JavaScript library React, can be used with the React Native JavaScript framework to build native applications. The ability to use JavaScript to develop applications for both iOS and Android is one of the many advantages of React Native. To build an iOS application, you don't need to know Objective-C or Swift, and to make an Android app, you don't need to know Java.&lt;/p&gt;

&lt;p&gt;Due to its ability to create a single application that runs on two separate OS platforms, React Native helps speed up development significantly. Additionally, because it makes use of React, you may employ components and benefit from their reusable nature. I strongly advise reading the &lt;a href="https://reactnative.dev/docs/getting-started"&gt;documentation&lt;/a&gt; for React Native, which is excellent in my opinion and offers nice and understandable examples. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Step #1&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Make sure the recent version of Node.js is installed on your machine. Run the following command in your terminal to determine what version you are using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;a href="https://nodejs.org/en/"&gt;here&lt;/a&gt; for information on installing or updating to the most recent version if you don't already have Node.js installed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step #2&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once you have Node.js installed run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g expo-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your PC will then have the Expo CLI installed globally. If you're using Mac OS, you might need to add sudo after the aforementioned command. Then, in order to access your computer, you must enter the password; &lt;br&gt;
with Windows, this is not essential.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step #3&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By executing the following command after the Expo CLI has been installed successfully, you can launch a brand-new project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expo init &amp;lt;name of project goes here&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the project is created, you must start the development server and change directories to the newly created folder. You can do this by executing the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd &amp;lt;name of project goes here&amp;gt;
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new window in your browser will open after you perform these instructions and provide details about your project.&lt;/p&gt;

&lt;p&gt;Here is an illustration of how this will function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expo init quiz-app
cd quiz-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have a brand-new React Native project, but how can you preview it. I'll address this concern in the part that comes next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preview Your Project&lt;/strong&gt;&lt;br&gt;
You must install the Expo Client App on your smartphone in order to preview your newly created project. You may either do this on the App Store or the Google Play Store, depending on the phone you have.&lt;/p&gt;

&lt;p&gt;After installing the Expo Client App, scan the QR Code that appeared when you typed &lt;code&gt;npm start&lt;/code&gt; into the terminal. You will first need to wait a few minutes when your project first bundles and loads. A brief notice will appear in the middle of the screen after the page has finished loading. That is essentially how your application is running right now.&lt;/p&gt;

&lt;p&gt;In the event that you only own an iPhone or an Android smartphone, you can use simulators to easily operate on both platforms. You must first download &lt;a href="https://developer.android.com/studio?gclid=Cj0KCQiAtrnuBRDXARIsABiN-7ANWy_2jX23GHocj9MWMcNmr1bs-ndjSYWDPBQ45cVrcptTbzlAgH0aAmqiEALw_wcB"&gt;Android Studio&lt;/a&gt; and Xcode in order to use the simulators.&lt;/p&gt;

&lt;p&gt;Due to Apple's restrictions, you will not be able to download Xcode if your operating system is Windows.&lt;/p&gt;

&lt;p&gt;Please click &lt;a href="https://docs.expo.dev/workflow/android-studio-emulator/?redirected"&gt;here&lt;/a&gt; for thorough instructions on setting up the Android simulator.&lt;/p&gt;

&lt;p&gt;Please click &lt;a href="https://docs.expo.dev/workflow/ios-simulator/?redirected"&gt;here&lt;/a&gt; for instructions on how to launch the iPhone simulator.&lt;/p&gt;

&lt;p&gt;That will sum it all up, thanks for reading, and I wish you well as you work to master React Native and Expo to become a top mobile app developer.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>mobile</category>
      <category>android</category>
    </item>
    <item>
      <title>Adding Routes to an Express Server PT(1)</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Tue, 04 Oct 2022 09:51:04 +0000</pubDate>
      <link>https://forem.com/ksowah/adding-routes-to-an-express-server-pt1-14b8</link>
      <guid>https://forem.com/ksowah/adding-routes-to-an-express-server-pt1-14b8</guid>
      <description>&lt;p&gt;Welcome back readers to another one of my boring but hopefully informative blogs. This time, we'll discuss adding routes to your Express.js server so that it can accommodate various client requests. If you're interested in reading my earlier article, where I showed how to build a Node.js server using the lightweight Express.js Node.js framework, please click &lt;a href="https://dev.to/ksowah/set-up-an-express-server-in-three-3-easy-steps-1gdp"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What we learnt in the earlier blog will serve as the basis for today's blog. An illustration of what we produced for the blog described above is shown 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%2Ff6dyfojy7iua7mj74cpg.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%2Ff6dyfojy7iua7mj74cpg.png" alt="express server"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we were able to develop a basic Express.js server with just four lines of code. I go into detail about what each line of code is doing and how we got here in my last &lt;a href="https://dev.to/ksowah/set-up-an-express-server-in-three-3-easy-steps-1gdp"&gt;blog&lt;/a&gt;. But enough with the past; let's go to work on expanding our server's routes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before continuing, I'm going to assume that you, the reader, have a basic understanding of HTTP request methods (or verbs). If not, click &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods" rel="noopener noreferrer"&gt;here&lt;/a&gt; and you'll be redirected to some excellent documentation that can provide you a foundational understanding of HTTP request methods.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is a picture of our `index.js file along with some more code.&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%2Fi1e8osh0axthscivezzr.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%2Fi1e8osh0axthscivezzr.png" alt="get request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By adding one of the HTTP methods, in this example the &lt;code&gt;GET&lt;/code&gt; method, to our &lt;code&gt;app&lt;/code&gt; constant, an instance of the express class (line 3), between lines 7 and 9, we created a route. Additionally, our &lt;code&gt;GET&lt;/code&gt; method expects two arguments: the route and a callback function, which holds the code to be run when the route is reached by our client.&lt;/p&gt;

&lt;p&gt;Additionally, the callback function anticipates two arguments: the &lt;code&gt;request&lt;/code&gt; and the &lt;code&gt;response&lt;/code&gt;. The request is an object that often includes data that the client sends. The &lt;code&gt;response&lt;/code&gt; is also an object that holds information and methods that helps the server return that information to the client.&lt;/p&gt;

&lt;p&gt;In this instance, on line 8, two methods are being chained to the &lt;code&gt;response&lt;/code&gt; object. The first method &lt;code&gt;status&lt;/code&gt; essentially informs the client if the request made to this route was successful or unsuccessful; in this case, we were providing a status code of &lt;code&gt;200&lt;/code&gt; signifying that it was successful (click &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status" rel="noopener noreferrer"&gt;here&lt;/a&gt; to learn more about status codes). The client might be able to present an alternative UI to the user depending on the &lt;code&gt;status&lt;/code&gt; code received, which improves the user experience, even though the status function is not necessary.&lt;/p&gt;

&lt;p&gt;The format of the data we are delivering back to our client is specified using the second method in our chain, which is &lt;code&gt;json&lt;/code&gt;. In this instance, we are enclosing a message in a &lt;code&gt;JSON&lt;/code&gt; object.&lt;/p&gt;

&lt;p&gt;finally finished building the first Express server route. How best can we test it? Instead of creating a UI to test, we can use a tool like &lt;a href="https://www.postman.com/" rel="noopener noreferrer"&gt;Postman&lt;/a&gt;. With Postman, you can test your server without having to make a client. If you are using &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VScode&lt;/a&gt; as your text editor, then you can use an extension in &lt;code&gt;VScode&lt;/code&gt; called &lt;code&gt;Thunder Client&lt;/code&gt;. Go to the extensions tab in &lt;code&gt;VScode&lt;/code&gt;, search &lt;code&gt;Thunder Client&lt;/code&gt; and install. We can easily test our routes with it and having the same development and test environment will save a lot of time. In this blog we will be using the &lt;code&gt;Thunder Client&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Below I have an image of the &lt;code&gt;Thunder Client&lt;/code&gt; UI.&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%2F3aonx6g9hazu6ajcj5j6.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%2F3aonx6g9hazu6ajcj5j6.png" alt="thunder client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt;, which is the address where our server is currently active. The input field denoted by the yellow arrow must contain the &lt;code&gt;url&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I have indicated where you can select the &lt;code&gt;HTTP&lt;/code&gt; method you want to use with a purple arrow. &lt;code&gt;GET&lt;/code&gt; is the default, therefore that will serve our purposes.&lt;/p&gt;

&lt;p&gt;To send a request to our server, click the blue arrow-pointing send button.&lt;/p&gt;

&lt;p&gt;The data we are getting from our server is indicated by the green arrow. If you recall, we indicated in line 8 of our index.js code that we needed a JSON-format response and an object to be returned with the message &lt;code&gt;"Hello World!"&lt;/code&gt; We did indeed receive that information back.&lt;/p&gt;

&lt;p&gt;After testing our server, we can say that both it and the first route we built are working properly. I'll demonstrate how to build routes that use the &lt;code&gt;POST&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; HTTP methods in a later article.&lt;/p&gt;

&lt;p&gt;I appreciate you reading, and I hope this article helped you understand how to add routes to your Express server.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Useful Array Methods In Javascript</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Sun, 21 Aug 2022 00:12:00 +0000</pubDate>
      <link>https://forem.com/ksowah/usefull-array-methods-in-javascript-4oaf</link>
      <guid>https://forem.com/ksowah/usefull-array-methods-in-javascript-4oaf</guid>
      <description>&lt;p&gt;The most popular programming language in use today is Javascript. The most recent &lt;a href="https://survey.stackoverflow.co/2022/#technology-most-popular-technologies" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt; developer survey is shown in the image 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%2Fw09d1k9inpn6be3g8zq8.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%2Fw09d1k9inpn6be3g8zq8.png" alt="2022 Stack Overflow developer survey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially, Javascript was mostly used to build straightforward dynamic webpages, but in the past decade or so, Javascript has seen significant development. It has developed into a programming language that can also be used to build mobile applications (&lt;a href="https://reactnative.dev/" rel="noopener noreferrer"&gt;React Native&lt;/a&gt;) and the backend of other applications (using &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Multiple data types make up Javascript as a programming language. The majority are regarded as primitives. A primitive is a data type or value that is neither an object nor has any methods. There are six primitive data types: symbol, null, boolean, number, and string as per the new ECMAScript 2015.&lt;/p&gt;

&lt;p&gt;This blog post will concentrate on the Array object and some of the most widely used Javascript built-in methods.&lt;/p&gt;

&lt;p&gt;In case you forgot, arrays are just lists of things. The list may include a variety of data kinds. The index of each item in the list can be used to refer to it. Javascript arrays are zero-based indexed, which means that the array's first element has an index of zero. Here are a few instances of arrays and how we can access any individual element within them.&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%2F9947lx1iskl2if72nyy9.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%2F9947lx1iskl2if72nyy9.png" alt="array indexing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;shift()&lt;/code&gt;&lt;br&gt;
The first element in an array can be eliminated using this array method. Returns the value of the element being removed at the same time.&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%2Fezpsxq5u4lxtr1qshts8.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%2Fezpsxq5u4lxtr1qshts8.png" alt="running node on command promp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that we created an array and saved it in the &lt;code&gt;array&lt;/code&gt; variable on the first line. The &lt;code&gt;shift()&lt;/code&gt; method was then used on it. As a result, it returned and deleted the array's first entry. The array's appearance after invoking the &lt;code&gt;shift()&lt;/code&gt; method is shown in the last line. Don't worry about the &lt;code&gt;undefined&lt;/code&gt; in the code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;unshift()&lt;/code&gt;&lt;br&gt;
This method allows you to easily add one or more elements to the start of an array and returns the new length of the array.&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%2F36rxl3hgw1elpzcdtrix.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%2F36rxl3hgw1elpzcdtrix.png" alt="javascript unshift() method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once more, a new array is created and stored to the variable called &lt;code&gt;arr&lt;/code&gt;. Then, we applied the &lt;code&gt;unshift()&lt;/code&gt; method, passing two arguments that represented the elements we wished to insert at the array's beginning. The length of the array comprising the recently added members is then returned by the method. The array's appearance following use of the &lt;code&gt;unshift()&lt;/code&gt; method is displayed in the final line of code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;push()&lt;/code&gt;&lt;br&gt;
The only difference between this method and &lt;code&gt;unshift()&lt;/code&gt; is that it appends one or more elements to the end of the array. After adding the new element, it also returns the array's length.&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%2Fmfzandjjq5osk3qtrei7.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%2Fmfzandjjq5osk3qtrei7.png" alt="js push method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the &lt;code&gt;push()&lt;/code&gt; method extended the array by two elements and returned the updated array length.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pop()&lt;/code&gt;&lt;br&gt;
The &lt;code&gt;pop()&lt;/code&gt; method removes and returns the last element from an array. The array's length is then updated by this method.&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%2Fjctbx9c9bg12gv8peu5a.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%2Fjctbx9c9bg12gv8peu5a.png" alt="js pop method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can probably tell by now that the &lt;code&gt;pop()&lt;/code&gt; method and the &lt;code&gt;shift()&lt;/code&gt; method are very similar. The only distinction is, the last element is removed by &lt;code&gt;pop()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;slice()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Slice()&lt;/code&gt; creates a shallow copy of a section of an array into a new array object that is picked at random from start to finish (end not included). The initial array won't be changed. The &lt;code&gt;slice()&lt;/code&gt; method requires at least one argument, which is the index at which the slice should start.&lt;/p&gt;

&lt;p&gt;The method will create a copy of the array starting at the specified index and continuing to the end of the array if only one argument is supplied to it. The &lt;code&gt;slice()&lt;/code&gt; method will return a copy of the array if a second argument is given, starting at the index indicated with the first argument and ending at the index specified with the second argument (not including the element with this index).&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%2Fd42hsuis1hx6cef560tq.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%2Fd42hsuis1hx6cef560tq.png" alt="JS slice method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go through the above code step by step. Similar to before, a variable was set to an array. The &lt;code&gt;slice()&lt;/code&gt; method is then called with just one argument. As you can see, the array copy created by the &lt;code&gt;slice()&lt;/code&gt; method spans from index 2 all the way to the end of the array. The original array was returned when I verified the value of the &lt;code&gt;arrTwo&lt;/code&gt; variable in the following line of code. This indicates that the original array is unaffected by the &lt;code&gt;slice()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;In the last line I added two arguments and it returned a copy of the elements within those indexes, but not including the element that has the index that is equal to the second argument passed to the method.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;includes()&lt;/code&gt;&lt;br&gt;
This method may check whether an array has a specific value, which makes it incredibly useful. If the value is in the array, it will return true, otherwise, if the value is not in the array, it will return false.&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%2F3jx50pea2zhlzedzmgaz.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%2F3jx50pea2zhlzedzmgaz.png" alt="JS includes method"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the example above, if we call the &lt;code&gt;includes()&lt;/code&gt; method on an array and feed it an argument, the method will determine whether the array has a value that is equal to the input. I want to draw your attention to the &lt;code&gt;includes()&lt;/code&gt; method's case sensitivity. In the last line of code, where it returned false, you can see an illustration of this. Although "david" is present in our array, it still returns false. The cause is that we gave the method "David" as an argument.&lt;/p&gt;

&lt;p&gt;There are other additional methods that may be applied to arrays and are included into Javascript. I'll cover methods for iterating over an array in a future blog post.&lt;/p&gt;

&lt;p&gt;I appreciate your reading and hope that this article has helped you better comprehend these methods.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>array</category>
      <category>methods</category>
      <category>functions</category>
    </item>
    <item>
      <title>Introduction to React Hooks 🪝</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Mon, 15 Aug 2022 22:56:18 +0000</pubDate>
      <link>https://forem.com/ksowah/introduction-to-react-hooks-5bg4</link>
      <guid>https://forem.com/ksowah/introduction-to-react-hooks-5bg4</guid>
      <description>&lt;p&gt;Welcome back, readers, to another blog where I attempt to demystify and clarify a specific web development topic. This blog post will concentrate on defining React Hooks and demonstrating how to use them in your React application.&lt;/p&gt;

&lt;p&gt;React is a JavaScript library that makes it simple to construct rich user interfaces and single page applications. You develop your user interface using components that you generate in React. State and props are two of the most essential React component features. A React component's state is an object that controls how the component renders and functions. Only class-based components could hold state prior to the invention of hooks. On the other hand, using props enables us to communicate with our components. The official &lt;a href="https://reactjs.org/"&gt;website&lt;/a&gt; is definitely a good place to start if you want to learn more about React.&lt;/p&gt;

&lt;p&gt;With the introduction of hooks in version 16.8 of the React library, you may now use state and other React capabilities without the need for classes. In other words, a functional component allows for the addition and modification of state. You can utilize a number of React hooks, but for the sake of this article, I'll concentrate on &lt;code&gt;useState&lt;/code&gt; which is one of the most crucial and widely used hooks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState Hook&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;useState&lt;/code&gt; hook enables us to use and control state inside a functional component. The &lt;code&gt;useState&lt;/code&gt; hook is used in the basic functional component shown below as an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D0K7dUW4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g510x5ykfms8c1f05vb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D0K7dUW4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g510x5ykfms8c1f05vb5.png" alt="useState hook code example" width="651" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This component is made up of an &lt;code&gt;input&lt;/code&gt; tag and a &lt;code&gt;h1&lt;/code&gt; tag. The information you type in the &lt;code&gt;input&lt;/code&gt; tag is shown in the &lt;code&gt;h1&lt;/code&gt; tag as you type.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;useState&lt;/code&gt; hook from the React library is imported in line one of the code above. However, line 5 of the code is the most crucial one. We start using our imported &lt;code&gt;useState&lt;/code&gt; hook here. In essence, the &lt;code&gt;useState&lt;/code&gt; hook is a function that takes an initial state. I passed an empty string in our example. A pair of values are returned in an array by the &lt;code&gt;useState&lt;/code&gt; hook.&lt;/p&gt;

&lt;p&gt;The array's first value is the state as it is at the moment, and its second value is a function that lets you modify or update the state. The two values are extracted from the array and stored in separate constants using array destructuring in the code above.&lt;/p&gt;

&lt;p&gt;In contrast to object destructuring, array destructuring allows you to use any name for your constants, but order is crucial. When naming your function, start with &lt;code&gt;set&lt;/code&gt;, you'll often use the format shown below, followed by the name of the constant you used to store the current state. as in "&lt;code&gt;setName&lt;/code&gt;," "&lt;code&gt;setAge&lt;/code&gt;," "&lt;code&gt;setColor&lt;/code&gt;," etc.&lt;/p&gt;

&lt;p&gt;We make use of the &lt;code&gt;setName&lt;/code&gt; method in the &lt;code&gt;onChange&lt;/code&gt; event on line 10. The &lt;code&gt;setName&lt;/code&gt; function receives the value of the input tag, which updates the state in this case, the &lt;code&gt;name&lt;/code&gt; constant.&lt;/p&gt;

&lt;p&gt;I would like to draw your attention to the fact that the &lt;code&gt;useState&lt;/code&gt; hook can be used many times within one functional component. See image below 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0rKzD_wt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zofdrzbwjjeihrjvhqz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0rKzD_wt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zofdrzbwjjeihrjvhqz6.png" alt="useState hook example" width="624" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading, and I hope this article gave you some insight into React hooks that you can utilize in the future.&lt;/p&gt;

</description>
      <category>react</category>
      <category>hook</category>
      <category>state</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Set up an Express Server in Three (3) Easy Steps 🔥</title>
      <dc:creator>Kelvin Sowah</dc:creator>
      <pubDate>Fri, 12 Aug 2022 00:40:49 +0000</pubDate>
      <link>https://forem.com/ksowah/set-up-an-express-server-in-three-3-easy-steps-1gdp</link>
      <guid>https://forem.com/ksowah/set-up-an-express-server-in-three-3-easy-steps-1gdp</guid>
      <description>&lt;p&gt;With my never ending quest to be a well versed Full Stack developer, I buried myself into the world of Node JS. Well if you happened to be a Node JS newbie, Node JS is an open source server environment that uses JavaScript on the server. A common task for a web server can be to open a file on the server (backend) and return the content to the client (frontend). There are other server side languages like Python, Ruby, Java, PHP etc.&lt;/p&gt;

&lt;p&gt;I decided to learn Node JS because first of all, its written in JavaScript, which means I can have both my frontend and backend written in one language, JavaScript. More importantly, JavaScript has a massive and growing community, this is extremely useful because it provides a great support system that you can lean on when you run into issues.   &lt;/p&gt;

&lt;p&gt;This brings me to Express JS which is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.&lt;/p&gt;

&lt;p&gt;Too much talk, lets start coding 👨‍💻.&lt;/p&gt;

&lt;p&gt;Before we start, make sure you have Node JS installed. To check, open your terminal or &lt;code&gt;cmd&lt;/code&gt; and run the command &lt;code&gt;node --version&lt;/code&gt; to check the version of node. If you don't have node installed click &lt;a href="https://nodejs.org/en/"&gt;here&lt;/a&gt; to install.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 1 - Set up Environment:&lt;/strong&gt;&lt;br&gt;
Now lets setup the environment for our server. First of all, create a folder called my-server. You can do this in the terminal with the command &lt;code&gt;mkdir my-server&lt;/code&gt;. Enter into the folder with the command &lt;code&gt;cd my-server&lt;/code&gt;. You can use any text editor of your choice but I'll be using Visual Studio Code. You can click &lt;a href="https://code.visualstudio.com/"&gt;here&lt;/a&gt; to download it.&lt;/p&gt;

&lt;p&gt;We now open our folder in our editor and run &lt;code&gt;npm init&lt;/code&gt; in the terminal. we're going to have to answer a series of questions most of which are not important. To skip this step, run &lt;code&gt;npm init -y&lt;/code&gt; instead.&lt;br&gt;
After running the command, a &lt;code&gt;package.json&lt;/code&gt; file will be created. Below is an image of the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PZqEPa4b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg0gc7zj6rppaqroas1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PZqEPa4b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg0gc7zj6rppaqroas1l.png" alt="a package json file" width="791" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;package.json&lt;/code&gt; will hold some basic information about your application. It also manages all the dependencies of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 2 - Install Necessary Dependencies&lt;/strong&gt;&lt;br&gt;
Now let's start to install some dependencies. First of all, we will install Express JS. We can do this by running the command &lt;code&gt;npm i express&lt;/code&gt; in the terminal. Make sure you're in the &lt;code&gt;my-server&lt;/code&gt; directory on the terminal. After the installation is done, you will see a folder called &lt;code&gt;node_modules&lt;/code&gt;, &lt;strong&gt;do not&lt;/strong&gt; edit this folder. It contains all the dependencies of Express JS and the dependencies of those dependencies. &lt;/p&gt;

&lt;p&gt;Another package we would want to install is &lt;code&gt;nodemon&lt;/code&gt;. This package will watch for any change in our code and automatically restart the server without us having to manually do it all the time. This is hence going to be used in development which means we wouldn't want to have it in production therefore we can install it as a dev dependency by running &lt;code&gt;npm i -D nodemon&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;package.json&lt;/code&gt; file should look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jeIckh2G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cucqoj5p14r9dejozikc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jeIckh2G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cucqoj5p14r9dejozikc.png" alt="How package json file should look when a package is installed" width="830" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let me explain the new changes in our &lt;code&gt;package.json&lt;/code&gt; file. On line 7 I added a &lt;code&gt;start&lt;/code&gt; script which will use nodemon to watch for changes in our &lt;code&gt;index.js&lt;/code&gt; file ( we will be creating this file soon ). This means that when I run &lt;code&gt;npm start&lt;/code&gt; in the terminal, our nodemon package will be started. Lines 9 - 11 shows all the dependencies we have installed. In this case Express. Then lines 15 - 17 shows all the dev dependencies. In this case nodemon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STEP 3 - Spin up Express Server&lt;/strong&gt;&lt;br&gt;
The next thing we want to do is to create an entry point to our application. To do this, create a new file called &lt;code&gt;index.js&lt;/code&gt;. I will show you my &lt;code&gt;index.js&lt;/code&gt; file and explain what the code is doing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nsYuk6lK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwfyayfsr1ujk023qsld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nsYuk6lK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwfyayfsr1ujk023qsld.png" alt="the entry point of an express server" width="880" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On line 1, I import express and store it in a constant.&lt;/p&gt;

&lt;p&gt;On line 3, I initialize express and store it in another constant.&lt;/p&gt;

&lt;p&gt;On line 5, we're saving the port to our server in a constant. The &lt;code&gt;process.env.PORT&lt;/code&gt; will check your environmental variables if a port number has been defined, otherwise it will use &lt;code&gt;port 8000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On line 7, we are using the inbuilt &lt;code&gt;listen&lt;/code&gt; method which expects at least one argument which is the port number. We can also pass a callback function as a second argument. In our case we are only logging to the console what port the server is running on.&lt;/p&gt;

&lt;p&gt;At this point, if you run &lt;code&gt;npm start&lt;/code&gt; in the terminal, you should see &lt;code&gt;nodemon&lt;/code&gt; running and a message saying "Server is running on port 8000".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TofOftWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wo2pqwcogsvpc7xrdrk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TofOftWY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wo2pqwcogsvpc7xrdrk.png" alt="nodemon server running" width="555" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hurray!! 🥳 you have a working express server. I'll be showing you how to set up routes to your server in later blogs.&lt;/p&gt;

&lt;p&gt;Thank you for reading and hopefully I have wet your appetite to learn more and experiment with Node JS and Express JS.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>express</category>
      <category>backend</category>
      <category>node</category>
    </item>
  </channel>
</rss>
