<?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: Blujay0</title>
    <description>The latest articles on DEV Community by Blujay0 (@blujay0).</description>
    <link>https://dev.to/blujay0</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%2F859200%2F27da2cfe-a44b-49e2-b700-a34ef518b871.png</url>
      <title>DEV Community: Blujay0</title>
      <link>https://dev.to/blujay0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/blujay0"/>
    <language>en</language>
    <item>
      <title>📧 Send Emails using React Forms</title>
      <dc:creator>Blujay0</dc:creator>
      <pubDate>Fri, 28 Jul 2023 10:45:22 +0000</pubDate>
      <link>https://dev.to/blujay0/send-emails-from-react-forms-21d8</link>
      <guid>https://dev.to/blujay0/send-emails-from-react-forms-21d8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;NOTE: &lt;code&gt;emailjs-com&lt;/code&gt; is deprecated. Use the current SDK which can be found &lt;a href="https://www.npmjs.com/package/emailjs"&gt;here&lt;/a&gt; or install using &lt;code&gt;npm install @emailjs/browser&lt;/code&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In this article, I will cover how to send emails from React Forms created in an example web application, using a free JavaScript library known as &lt;strong&gt;EmailJS&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Your React Form
&lt;/h2&gt;

&lt;p&gt;Begin by creating a 'Contact Us' component and inside, we will have our form. For the purpose of this article, I have created a simple form with basic styling:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Ph4gfIh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub50drb51neg8z0s691d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Ph4gfIh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub50drb51neg8z0s691d.png" alt="1. ContactUsForm" width="761" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrate EmailJS into the application
&lt;/h2&gt;

&lt;p&gt;First, in the terminal of the code editor, &lt;code&gt;cd&lt;/code&gt; to the /client directory of the app, and install EmailJS with the following command: &lt;code&gt;npm i emailjs-com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G-ROcj2j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83sh97dtoyuqddsvaw3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G-ROcj2j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83sh97dtoyuqddsvaw3b.png" alt="2. npm-install-emailjs" width="668" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we import &lt;em&gt;emailjs&lt;/em&gt; into our &lt;code&gt;&amp;lt;ContactUs /&amp;gt;&lt;/code&gt; component like so:&lt;br&gt;
&lt;code&gt;import emailjs from 'emailjs-com'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Before we go further, let's create the free EmailJS account!&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a Free EmailJS Account + Email Service
&lt;/h2&gt;

&lt;p&gt;Go ahead to the &lt;a href="https://www.emailjs.com"&gt;EmailJS&lt;/a&gt; website and signup for a free account. They allow up to 200 emails per month for free.&lt;br&gt;
Once you successfully signup and login, you will be brought to this page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4OXQpLLd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v521aenrno41spugjca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4OXQpLLd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v521aenrno41spugjca.png" alt="3. EmailJS-firstpage" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Add New Service&lt;/strong&gt; button near the top and choose the email provider of your choice:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KY5w8hti--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yvrz2klxb5zaszvl473.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KY5w8hti--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yvrz2klxb5zaszvl473.png" alt="4. add-new-service" width="800" height="521"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the following window, press &lt;strong&gt;Connect Account&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5hRE4op2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjzjtx3ekmkpeg7gs065.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5hRE4op2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjzjtx3ekmkpeg7gs065.png" alt="5. Connect-Account" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A window will pop-up that will ask you which Gmail account you wish to choose to continue with EmailJS. Then, you need to allow EmailJS a certain amount of access to your Google Account (this is standard procedure).&lt;/p&gt;

&lt;p&gt;When that's done, you will be able to finally press the &lt;strong&gt;Create Service&lt;/strong&gt; button and you should see a new service added on your &lt;strong&gt;Email Services&lt;/strong&gt; page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QfgntWLY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nedrrrfyfcafdz54khpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QfgntWLY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nedrrrfyfcafdz54khpz.png" alt="7. service-id-added" width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Create an Email Template
&lt;/h2&gt;

&lt;p&gt;Now we need to create a template that our email will follow. The navigation bar on the left has an option for &lt;em&gt;Email Templates&lt;/em&gt;, press it and you should be taken to the &lt;strong&gt;Email Templates&lt;/strong&gt; page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WriTO4Kn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/degxt41g2duswpn5v8c4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WriTO4Kn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/degxt41g2duswpn5v8c4.png" alt="8. email-templates-page" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice the &lt;strong&gt;Create New Template&lt;/strong&gt; button near the top. Press it and you will be taken to a form page where you can fill out the necessary information to create your template:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WwUBDC0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45835nkeuvz3mpvd9sot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WwUBDC0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45835nkeuvz3mpvd9sot.png" alt="9. template-form-page" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, notice the &lt;code&gt;{{to_name}}&lt;/code&gt;, &lt;code&gt;{{from_name}}&lt;/code&gt;,  &lt;code&gt;{{message}}&lt;/code&gt;, and &lt;code&gt;{{reply_to}}&lt;/code&gt; on the forms. To know what we need to place in these double curly braces, we need to look at our code for the form:&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;form style={{marginLeft: "100px"}} onSubmit={sendEmail}&amp;gt;
        &amp;lt;h1 style={{fontSize: "50px"}}&amp;gt;Contact Us&amp;lt;/h1&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;label style={{fontSize: "25px"}}&amp;gt;Name: &amp;lt;/label&amp;gt;
          &amp;lt;input type='text' name='user_name' style={{fontSize: "25px"}}/&amp;gt;        
        &amp;lt;/div&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;label style={{fontSize: "25px"}}&amp;gt;Email: &amp;lt;/label&amp;gt;
          &amp;lt;input type='email' name='user_email' style={{fontSize: "25px"}}/&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;br /&amp;gt;
        &amp;lt;div&amp;gt;
          &amp;lt;label style={{fontSize: "25px"}}&amp;gt;Message: &amp;lt;/label&amp;gt;
          &amp;lt;br /&amp;gt;
          &amp;lt;textarea name='user_message' rows='6' cols="50" style={{fontSize: "25px"}}/&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;input type='submit' value='Send' style={{backgroundColor: "#87CEEB", color: "black", padding: "8px 32px", margin: "4px 2px", fontSize: "20px"}}/&amp;gt;
      &amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each &lt;code&gt;&amp;lt;input/&amp;gt;&lt;/code&gt; element in the form, note the &lt;code&gt;name&lt;/code&gt; attributes and their values. The values of the &lt;code&gt;name&lt;/code&gt; attributes are what we are going to pass into double curly braces on our email template form. For example, the value of the &lt;code&gt;name&lt;/code&gt; attribute of the &lt;code&gt;&amp;lt;textarea/&amp;gt;&lt;/code&gt; element is &lt;code&gt;user_message&lt;/code&gt; so that is what we will pass inside the curly brace of &lt;code&gt;{{message}}&lt;/code&gt; in our email template form.&lt;/p&gt;

&lt;p&gt;Going by that logic, we can replace &lt;code&gt;{{from_name}}&lt;/code&gt; plus the &lt;em&gt;From Name&lt;/em&gt; box with &lt;code&gt;{{user_name}}&lt;/code&gt;, &lt;code&gt;{{message}}&lt;/code&gt; with &lt;code&gt;{{user_message}}&lt;/code&gt;, and you can fill in the &lt;em&gt;From Email&lt;/em&gt; box with &lt;code&gt;{{user_email}}&lt;/code&gt;. The &lt;code&gt;{{to_name}}&lt;/code&gt; can be left blank for our purposes and it will just render as blank space in the email once it is sent:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r88SzyAP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f97414zslqu67a15jgju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r88SzyAP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f97414zslqu67a15jgju.png" alt="10. filled-template-form" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: remember to put your email address in the &lt;em&gt;To Email&lt;/em&gt; text field so you can receive the email(s) in the format set by your template. Obviously, you can change the email address later, based on who you want the automated messages to be sent to!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Create a submit handler function for the form
&lt;/h2&gt;

&lt;p&gt;Now that that is all setup, we need to create our submit handler for our form. We will need three things from EmailJS: the &lt;strong&gt;Service ID&lt;/strong&gt;, &lt;strong&gt;Template ID&lt;/strong&gt;, and your &lt;strong&gt;Public or Private Key&lt;/strong&gt; that can be found in your &lt;code&gt;Account&lt;/code&gt; page in your navigation bar.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;ContactUs&lt;/code&gt; component, create the following submit handler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sendEmail = (e) =&amp;gt; {
  e.preventDefault();

  emailjs.sendForm(
    "YOUR_SERVICE_ID", 
    "YOUR_TEMPLATE_ID", 
    e.target, 
    "PUBLIC_KEY"
    ).then(res =&amp;gt; {
      console.log(res);
    }).catch( err=&amp;gt; console.log(err));
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And make sure to pass it to the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element as a value to the &lt;code&gt;onSubmit&lt;/code&gt; attribute! You can see what I mean by looking at the &lt;/p&gt; code from before.
&lt;h2&gt;
  
  
  Test It Out!
&lt;/h2&gt;

&lt;p&gt;Time to check if it works! &lt;br&gt;
Let's fill out the form with some dummy info and hit &lt;em&gt;Send&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q3k70WnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlbph4vtub3p5nbkpw62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q3k70WnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlbph4vtub3p5nbkpw62.png" alt="11. fill-form-dummy-text" width="752" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... and success! You should have received an email with the contents in the format set by the template that you defined:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qIeLnG47--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4bf8eac5o707prstqsb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qIeLnG47--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4bf8eac5o707prstqsb.png" alt="12. success-receive-email" width="264" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion &amp;amp; Further Considerations
&lt;/h2&gt;

&lt;p&gt;Email sending functionality is commonplace in web development. Most websites that you construct will be required to send automatic emails.&lt;/p&gt;

&lt;p&gt;Now, we've only covered frontend email integration, but email integrations become very powerful when used on the server-side.&lt;/p&gt;

&lt;p&gt;Just think of the multitude of use-cases for automated emails:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;update a customer on the shipping status of their order&lt;/li&gt;
&lt;li&gt;cart abandonment emails&lt;/li&gt;
&lt;li&gt;notifications about wishlisted products being on sale&lt;/li&gt;
&lt;li&gt;birthday emails&lt;/li&gt;
&lt;li&gt;event invitation emails&lt;/li&gt;
&lt;li&gt;welcome emails&lt;/li&gt;
&lt;li&gt;reward/loyalty point emails&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...the list goes on and on...&lt;/p&gt;

&lt;p&gt;And that's that! I hope you found this article useful and happy coding!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/Blujay0/WatchList"&gt;WatchList&lt;/a&gt; - the git repo where you can find the example used in this article&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.emailjs.com"&gt;EmailJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://smtpjs.com"&gt;Smtpjs&lt;/a&gt; - a similar free library like EmailJS that you can use to send emails from JavaScript&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/"&gt;React Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.brevo.com/blog/email-automation-examples/"&gt;Article on some email automation examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>frontend</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Quick Look: Reading and Writing to CSV Files</title>
      <dc:creator>Blujay0</dc:creator>
      <pubDate>Fri, 30 Jun 2023 14:18:40 +0000</pubDate>
      <link>https://dev.to/blujay0/quick-look-reading-and-writing-to-csv-files-4dk6</link>
      <guid>https://dev.to/blujay0/quick-look-reading-and-writing-to-csv-files-4dk6</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;CSV&lt;/strong&gt; stands for &lt;strong&gt;Comma Seprated Values&lt;/strong&gt; and is a popular format for storing tabular/table-like data in a file to use. This tabular data can consist of things like financial transactions, payroll, and other statistical records of information.&lt;/p&gt;

&lt;p&gt;Here is an example of a CSV file randomly generated from &lt;a href="http://www.randat.com/" rel="noopener noreferrer"&gt;Random Data Generator&lt;/a&gt; opened in VSCode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"First Name", "Last Name", "Age", "Experience (Years)", "Salary"
"Roland", "Cooper", "22", "6", "7516"
"Edith", "Reed", "19", "1", "2147"
"Aida", "Montgomery", "24", "11", "7009"
"Dominik", "Moore", "18", "6", "9427"
"Chloe", "Lloyd", "25", "6", "4715"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first row ALWAYS represents the column headers and the rest of the rows represent the actual data that goes into the table.&lt;/p&gt;

&lt;p&gt;Here is a visual representation of the above CSV for you visual learners:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yk7agusuw1q5l8hnzcw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yk7agusuw1q5l8hnzcw.png" alt="CSV represented as table" width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  What We'll Be Using:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;CSV file(s)&lt;/li&gt;
&lt;li&gt;VSCode's CSV Module&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Reading the CSV File
&lt;/h1&gt;

&lt;p&gt;To read our CSV file, we'll be using the &lt;strong&gt;reader()&lt;/strong&gt; function provided by the CSV module. This function allows you to iterate over rows of the CSV as lists and returns an iterable &lt;em&gt;reader&lt;/em&gt; object.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example Code
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# create a use_reader.py file in your base directory
# first you import reader from VSCode's CSV module
from csv import reader

# open() is used to open a CSV file for reading
with open("random.csv") as csvfile:

    # set csv_reader variable to the evaluated result of invoking reader(csvfile)
    csv_reader = reader(csvfile)

    print(csv_reader)

    for row in csv_reader:
        print(row)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Terminal &amp;amp; Results
&lt;/h2&gt;

&lt;p&gt;With the code above setup, open your terminal and run &lt;em&gt;python3 use_reader.py&lt;/em&gt;. You should get something similar to the following result:&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;_csv.reader object at 0x7f3121352120&amp;gt;

['First Name', 'Last Name', 'Age', 'Experience (Years)', 'Salary']
['Roland', 'Cooper', '22', '6', '7516']
['Edith', 'Reed', '19', '1', '2147']
['Aida', 'Montgomery', '24', '11', '7009']
['Dominik', 'Moore', '18', '6', '9427']
['Chloe', 'Lloyd', '25', '6', '4715']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first return is a representation of the iterable reader object that is returned from running the &lt;em&gt;reader()&lt;/em&gt; function.&lt;br&gt;
The second return is each element of the object that we iterated over with the &lt;em&gt;for...in&lt;/em&gt; loop.&lt;/p&gt;

&lt;h1&gt;
  
  
  Writing to CSV Files
&lt;/h1&gt;

&lt;p&gt;To write to CSV files, we'll be using the &lt;strong&gt;writer()&lt;/strong&gt; function provided by the CSV module. This function allows you to create a &lt;em&gt;writer&lt;/em&gt; object and create a new CSV file if needed. This can be seen as a counterpart to the &lt;strong&gt;reader()&lt;/strong&gt; function. The method that is frequently used is &lt;strong&gt;writerow()&lt;/strong&gt; which allows you to input a row to the CSV. The &lt;strong&gt;writerow()&lt;/strong&gt; method takes in a list of values that you want to input for each row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# create a use_writer.py file in your base directory
# first you import writer from VSCode's CSV module
from csv import writer

# "open() is used to open a CSV file for reading"
# the "w" is declaring that this will be writing to the CSV file
with open("create_new.csv", "w") as csvfile:
    # set csv_writer variable to the evaluated result of invoking writer(csvfile)
    csv_writer = writer(csvfile)

    # pass into writerow() a list of data points you wish to write to the CSV file
    csv_writer.writerow(["First Name", "Last Name", "Age", "Experience (Years)", "Salary"])
    csv_writer.writerow(["Steven", "Spielberg", "64", "42", "60000000"])
    csv_writer.writerow(["George", "Lucas", "58", "35", "50000000"])
    csv_writer.writerow(["Christopher", "Nolan", "52", "27", "20000000"])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Terminal &amp;amp; Results
&lt;/h2&gt;

&lt;p&gt;With the code above setup, open your terminal and run &lt;em&gt;python3 use_writer.py&lt;/em&gt;. You should see a new CSV file called &lt;em&gt;create_new&lt;/em&gt; in your directory and if you examine the file, you will see the data that you created using &lt;em&gt;writerow&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;And that file will translate to the following table:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fes7y8fs0tason5ufiv2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fes7y8fs0tason5ufiv2r.png" alt="written CSV table" width="800" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;reader()&lt;/em&gt; and &lt;em&gt;writer()&lt;/em&gt; methods allow for easy modifications of the data in a text editor for large datasets.&lt;/li&gt;
&lt;li&gt;It is a frequently-used format of data inputting and outputting because it is so widely adopted&lt;/li&gt;
&lt;li&gt;Useful to know if you are working with large datasets and pickling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that was a quick look at reading and writing to CSV files. Happy Coding!&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.synopsys.com/blogs/software-security/python-pickling/#:~:text=Pickle%20in%20Python%20is%20primarily,transport%20data%20over%20the%20network." rel="noopener noreferrer"&gt;Pickling (synopsys article)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tutorialspoint.com/python-pickling" rel="noopener noreferrer"&gt;Python Pickling (tutorialspoint)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.randat.com/" rel="noopener noreferrer"&gt;Random Data Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/csv.html" rel="noopener noreferrer"&gt;Python Documentation: CSV Reading and Writing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.programiz.com/python-programming/reading-csv-files#:~:text=csv%20file%20in%20reading%20mode%20using%20open()%20function.&amp;amp;text=Then%2C%20the%20csv.,returns%20an%20iterable%20reader%20object." rel="noopener noreferrer"&gt;Reading CSV files in Python (programiz)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/python-csv/" rel="noopener noreferrer"&gt;Reading and Writing CSV Files in Python (Real Python)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://flatfile.com/blog/what-is-a-csv-file-guide-to-uses-and-benefits/" rel="noopener noreferrer"&gt;What is a CSV File? (flatfile)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>python</category>
      <category>csv</category>
    </item>
    <item>
      <title>Quick Look: Web Scraping</title>
      <dc:creator>Blujay0</dc:creator>
      <pubDate>Fri, 09 Jun 2023 18:44:11 +0000</pubDate>
      <link>https://dev.to/blujay0/quick-look-web-scraping-5en4</link>
      <guid>https://dev.to/blujay0/quick-look-web-scraping-5en4</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;The concept of &lt;strong&gt;web Scraping&lt;/strong&gt; is to write code that programmatically takes data from a web page. This data is often in the form of HTML and the scraper code can be written to extract the data out of that HTML. This article will cover what web scraping is, the ethics of using a scraper, and the tools needed to scrape.&lt;/p&gt;

&lt;p&gt;There are three main steps to web scraping:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the HTML&lt;/li&gt;
&lt;li&gt;Extract Data from HTML&lt;/li&gt;
&lt;li&gt;Save &amp;amp; Use Scraped Data&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Use Case and Ethics
&lt;/h1&gt;

&lt;p&gt;Why would one need to use a web scraper? It is often the case that websites do not provide the information in their database in a easy-to-understand format to the public willy nilly. This may make it difficult to get just the data that you want which is where web scraping comes in.&lt;/p&gt;

&lt;p&gt;Say you were looking at a list of apartments on a site like Zillow and want to chart the change in rent price over a 5 years to get a sense of when the best time to rent an apartment is. Now, Zillow does not have a public API for easy access to the properties on their databse. An alternative is to use web scraping where you write code that will extract the data you want from the HTML of a web page. This is much more effecient than manually grabbing and pasting the data yourself.&lt;/p&gt;

&lt;p&gt;The obvious question here is: &lt;strong&gt;"Is web scraping ethical?"&lt;/strong&gt;&lt;br&gt;
The answer depends. Technically, there is no law that states that you cannot use web scraping and the HTML on web pages are publicly available to anyone who has access to the page. &lt;/p&gt;

&lt;p&gt;If used for simple data, for your personal use, then there is no real problem. However, if you use it to create a clone of a website, make profit off of it, and the original website catches on, this could spell legal trouble!&lt;/p&gt;

&lt;p&gt;The convention is to be polite and respect what the website owners want if they have a position on their data's privacy.&lt;/p&gt;
&lt;h1&gt;
  
  
  Tools: Beautiful Soup
&lt;/h1&gt;

&lt;p&gt;To actually scrape data from a site, you can use web scraping tools which are programmed to parse through a site and grab data.&lt;/p&gt;

&lt;p&gt;First, you manually make a reqeust to get the HTML data that you can parse through. This is done with a &lt;em&gt;&lt;strong&gt;get()&lt;/strong&gt;&lt;/em&gt; request to a site which returns data, and you use that data with a web scraping software of your choice.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Second, you need web scraping software that will help parse through the HTML that is returned from the request. &lt;strong&gt;Beautiful Soup&lt;/strong&gt;, for example, is a package you can install in your local environment that allows the extraction of data from the HTML returned from your request using Python.&lt;/p&gt;

&lt;p&gt;To install Beautiful Soup, run this in your command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m pip install bs4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Utilization
&lt;/h2&gt;

&lt;p&gt;Third, assuming you have an HTML document that gets returned from the request, you can now use Beautiful Soup to extract whatever information you want. To use it with your returned HTML, you must import it first in your HTML doc:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from bs4 import BeautifulSoup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, we turn the returned HTML into an &lt;strong&gt;object instance&lt;/strong&gt; of Beautiful Soup. To do this, you create a variable and assign it the evaluated result. Here is a way to do that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;souped = BeautifulSoup(html, "html.parser")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, you have access to the BeautifulSoup methods such as &lt;em&gt;&lt;strong&gt;fetch_all()&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;find_parent()&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;find_previous_sibling()&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;replace_with()&lt;/strong&gt;&lt;/em&gt;, etc. that you can invoke on the Beautiful Soup instance.&lt;/p&gt;

&lt;h1&gt;
  
  
  Takeaways
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7yhfsoolumfd38ld1ee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7yhfsoolumfd38ld1ee.png" alt="Web Scraping Process" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Scraping&lt;/strong&gt; is a way of grabbing information in a structured form efficiently. However, questions have been raised about the ethical nature of its usage. The convention is to be polite and aware of the site owner's preferences.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.imperva.com/learn/application-security/web-scraping-attack/#:~:text=Web%20scraping%20is%20the%20process,replicate%20entire%20website%20content%20elsewhere." rel="noopener noreferrer"&gt;Web Scraping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/what-is-web-scraping-and-how-to-use-it/" rel="noopener noreferrer"&gt;What is Web Scraping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Web_scraping" rel="noopener noreferrer"&gt;Wikipedia: Web scraping &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://careerfoundry.com/en/blog/data-analytics/web-scraping-guide/#how-does-a-web-scraper-function" rel="noopener noreferrer"&gt;What Is Web Scraping?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.upwork.com/resources/web-scraping-basics" rel="noopener noreferrer"&gt;Web scraping basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a&gt;Wikipedia: Beautiful Soup&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webscraping</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Quick Look: What is Redux?</title>
      <dc:creator>Blujay0</dc:creator>
      <pubDate>Fri, 19 May 2023 13:09:05 +0000</pubDate>
      <link>https://dev.to/blujay0/quick-look-redux-4ohi</link>
      <guid>https://dev.to/blujay0/quick-look-redux-4ohi</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;This article will be a basic conceptual overivew of what Redux is, what it is used for, and how it works.&lt;/p&gt;

&lt;h1&gt;
  
  
  Quick useState Hook Refresher
&lt;/h1&gt;

&lt;p&gt;Before we continue, let's review the useState() hook real quick. It helps us manage data that can change (for example, when a button is clicked) and changes to that data leads to the UI being udpated. State management hooks allow us to tell React that some data changed so that it can udpate the UI for us and keep track of that change in a state variable.&lt;br&gt;
Remember, &lt;strong&gt;state&lt;/strong&gt; is an object that is built into React that keeps track of data about the component that it exists in. Whenever state changes, the component re-renders.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Redux?
&lt;/h1&gt;

&lt;p&gt;Redux is a JavaScript library that is a &lt;strong&gt;state management system&lt;/strong&gt; for cross-component or app-wide state. What does this mean? It let's us manage state that affects multiple components or even the entire app.&lt;br&gt;
State can exist for just a single component, but it can also exist for mutiple components. It can even exist for the entire application! State for multiple components require, &lt;strong&gt;prop drilling&lt;/strong&gt; which is the concept of passing state down as props to different components that need it. &lt;br&gt;
However, passing around data and updating functions from props can become tedious. Redux allows us to avoid prop chains and gives us a central place to control state.&lt;/p&gt;

&lt;h1&gt;
  
  
  Key Concepts
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Redux is about having one central state storage in your application.&lt;/strong&gt; This storage is for &lt;em&gt;all&lt;/em&gt; the states you need in the entire application. Data in this central store is used by components and components set up &lt;strong&gt;subscrtiptions&lt;/strong&gt; to the central store of information/state. This way, whenever the data in the central data store changes, it can "notify" the components so that the components can get the data that they need and use it. They don't get the entire data from the central store, they just get the "slice" of the central state that they need.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Components &lt;em&gt;never&lt;/em&gt; change the central store of data.&lt;/strong&gt; There is dat being passed down from the central state database to components through subscriptions, but no direct information flow back up from the components. Instead, &lt;strong&gt;reducer&lt;/strong&gt; functions are used and are responsible for updating the central state database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Components trigger data change in the central data storage.&lt;/strong&gt; But, if there is no direct information flow back up to the central data store from components, then the only reasonable method with what we have learned so far, would be some sort of connection between the components and the reducer function. How does this conneciton occur? Through something called &lt;strong&gt;actions&lt;/strong&gt; and components &lt;strong&gt;dispatch&lt;/strong&gt; these actions. An &lt;em&gt;action&lt;/em&gt; is a JavaScript object that defines the kind of operation that the reducer should perform. This is where Redux comes in and passes along or &lt;strong&gt;forwards&lt;/strong&gt; the &lt;em&gt;action&lt;/em&gt; to the reducer function. The reducer then reads the instructions and executes what the component is asking for.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Information Flow
&lt;/h1&gt;

&lt;p&gt;Here is the information flow to review:&lt;br&gt;
Central Data/State Store -(subscription)-&amp;gt; Components -(dispatch)-&amp;gt; Action -(forwarding)-&amp;gt; Reducer -(execution)-&amp;gt; Central Data/State Store --&amp;gt; REPEAT&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprx5ujoc81uct8hijha7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprx5ujoc81uct8hijha7.png" alt="Redux Info Flow Chart" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;As React applications grow in size, so will the number of components that are built in it. With all those components, it can become tedious to pass down state data as props to all the child compoennts. Redux allows components to take slices of the central state storage and these slices contain only the infomation that each component needs.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resoruces
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redux.js.org/" rel="noopener noreferrer"&gt;redux.js.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/swlh/what-is-redux-b16b42b33820" rel="noopener noreferrer"&gt;Medium article on Redux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/what-is-redux-store-actions-reducers-explained/" rel="noopener noreferrer"&gt;freeCodeCamp: Redux for Beginners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://legacy.reactjs.org/docs/hooks-state.html" rel="noopener noreferrer"&gt;reactjs.org doc on useState&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/react/react_usestate.asp" rel="noopener noreferrer"&gt;w3schools on useState&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.google.com/search?q=three+typs+of+state+react&amp;amp;rlz=1C1RXQR_enUS1037US1037&amp;amp;ei=VWlnZPWcObTK9AOotLWgBA&amp;amp;ved=0ahUKEwi1m674roH_AhU0JX0KHShaDUQQ4dUDCBA&amp;amp;uact=5&amp;amp;oq=three+typs+of+state+react&amp;amp;gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIHCCEQoAEQCjIKCCEQFhAeEB0QCjIKCCEQFhAeEB0QCjIKCCEQFhAeEB0QCjIKCCEQFhAeEB0QCjIKCCEQFhAeEB0QCjIKCCEQFhAeEB0QCjoKCAAQRxDWBBCwAzoHCAAQDRCABDoGCAAQHhANOggIABAFEB4QDToKCAAQBRAeEA0QDzoICAAQCBAeEA06CAgAEIoFEIYDOgYIABAWEB5KBAhBGABQmQFY4QdgyQhoAXABeACAAYcBiAHfBJIBAzUuMZgBAKABAcgBCMABAQ&amp;amp;sclient=gws-wiz-serp" rel="noopener noreferrer"&gt;freeCodeCamp: How to Manage State in Your React Apps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>redux</category>
      <category>react</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Quick Look: How to Use APIs</title>
      <dc:creator>Blujay0</dc:creator>
      <pubDate>Fri, 28 Apr 2023 06:34:18 +0000</pubDate>
      <link>https://dev.to/blujay0/how-to-use-apis-1ion</link>
      <guid>https://dev.to/blujay0/how-to-use-apis-1ion</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;This article will cover APIs: what they are, what they do, and the simplest way make an API call using the &lt;strong&gt;National Park Service API&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is an API?
&lt;/h1&gt;

&lt;p&gt;An &lt;strong&gt;Application Programming Interface&lt;/strong&gt;, or &lt;strong&gt;API&lt;/strong&gt; for short, is a set of rules used by programs to communicate with each other. It is a vital part of communication between the frontend (client-side) and the backend (server-side).&lt;/p&gt;

&lt;h1&gt;
  
  
  What do APIs do?
&lt;/h1&gt;

&lt;p&gt;An API facilitates the &lt;strong&gt;request-response cycle&lt;/strong&gt; between the client and the server. A frequently used analogy for this cycle is to think of an API as a waiter in a restaurant that acts as a middleman between the customers and the kitchen. In programming terms, the customer is the client and the kitchen is the backend-server. &lt;br&gt;
Here is a simple example of the cycle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a client makes a request to the API&lt;/li&gt;
&lt;li&gt;the API processes the request and makes a call to the server&lt;/li&gt;
&lt;li&gt;the server receives the API call and repsonds with data&lt;/li&gt;
&lt;li&gt;API processes the data and delivers it to the client&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  API Access
&lt;/h1&gt;

&lt;p&gt;Not all APIs are open for public use and understandably so. The server-side database may belong to a bank holding sensitive and private information about their customers. It is probably not a good idea to give random people access to this information through an API.&lt;br&gt;
However, there are plenty of APIs that are open for the public to use. Thankfully, lists exist of public APIs and a few links have been added at the bottom of this article in the "References" section.&lt;br&gt;
Some of these public APIs require no authorization while others do. There are different types of authorizations such as an &lt;strong&gt;API key&lt;/strong&gt; or &lt;strong&gt;OAuth&lt;/strong&gt;. This article will focus on using an API key.&lt;/p&gt;
&lt;h1&gt;
  
  
  Generating an API Key
&lt;/h1&gt;

&lt;p&gt;Before you use make a API call, you need to have one first! We'll using the &lt;strong&gt;National Park Service API&lt;/strong&gt; for this example. Fill out this &lt;a href="https://www.nps.gov/subjects/developer/get-started.htm" rel="noopener noreferrer"&gt;form&lt;/a&gt; on their site and your key will be emailed to you. It will be a mix of letters and numbers in this case. This key acts like your ID card and keeps track of the number of requests you make. Thankfully, NPS allows up to 1,000 requests per hour which is normally more than enough.&lt;/p&gt;
&lt;h1&gt;
  
  
  Creating a URL to Make the API Request
&lt;/h1&gt;

&lt;p&gt;In order to make a API call/request, the API key needs to be saved in a variable in your JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const API_KEY = "your_key_here_in_quotes";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://www.nps.gov/subjects/developer/api-documentation.htm#/parks/getPark" rel="noopener noreferrer"&gt;NPS Documentation&lt;/a&gt; will provide you with information on how to format the URL to make the API request. In our case, we just want data about parks so the format would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getParks = `https://developer.nps.gov/api/v1/parks?api_key=${API_KEY}`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; you can just use the URL as is, but it makes it easier to re-use and makes for cleaner code if we save it to a variable.&lt;/p&gt;

&lt;h1&gt;
  
  
  Making the API Call with Another API
&lt;/h1&gt;

&lt;p&gt;Now, to actually make the request we need to use the &lt;strong&gt;Fetch API&lt;/strong&gt;. The Fetch API is built into the browser and gives you access to the &lt;strong&gt;fetch()&lt;/strong&gt; method which takes one required arugment. This argument is the path to the data that we are requesting which we have saved in our &lt;em&gt;getParks&lt;/em&gt; variable!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch(getParks);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This retreives the data you are requesting, but how do we use that data? That is a topic for another article.&lt;/p&gt;

&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.nps.gov/subjects/digital/nps-data-api.htm" rel="noopener noreferrer"&gt;National Park Service API License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nps.gov/subjects/developer/get-started.htm" rel="noopener noreferrer"&gt;Request NPS API Key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/API" rel="noopener noreferrer"&gt;MDN: APIs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" rel="noopener noreferrer"&gt;MDN: Fetch API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://apilist.fun/" rel="noopener noreferrer"&gt;API List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/public-apis/public-apis" rel="noopener noreferrer"&gt;public-apis repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rapidapi.com/collection/list-of-free-apis" rel="noopener noreferrer"&gt;Rapid API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>api</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
