<?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: Hannah</title>
    <description>The latest articles on Forem by Hannah (@wolfdominion).</description>
    <link>https://forem.com/wolfdominion</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%2F375062%2F8bfd89fd-cc01-4254-b2cf-783b24a249b8.png</url>
      <title>Forem: Hannah</title>
      <link>https://forem.com/wolfdominion</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/wolfdominion"/>
    <language>en</language>
    <item>
      <title>Build a Website Series Part 2: NodeJS CRUD with Postgres</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Sun, 01 Nov 2020 03:06:11 +0000</pubDate>
      <link>https://forem.com/wolfdominion/build-a-pern-website-part-2-nodejs-crud-api-with-postgres-57ma</link>
      <guid>https://forem.com/wolfdominion/build-a-pern-website-part-2-nodejs-crud-api-with-postgres-57ma</guid>
      <description>&lt;p&gt;&amp;lt;&amp;lt; &lt;a href="https://dev.to/wolfdominion/build-a-website-series-part-1-set-up-react-with-routes-and-navbar-la2"&gt;Part 1: React Routes&lt;/a&gt; || Next tutorial &amp;gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;The previous tutorial showed how to set up React with routes and a navbar. Next, we are going to focus on the backend setup. &lt;/p&gt;

&lt;p&gt;If needed, here is my &lt;a href="https://github.com/wolf-dominion/Bird_banders_api" rel="noopener noreferrer"&gt;repo&lt;/a&gt; to refer to. Now on to making the backend!&lt;/p&gt;

&lt;h2&gt;
  
  
  What Part 2 Covers:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Set up a nodeJS API&lt;/li&gt;
&lt;li&gt;Set up a PostgresSQL Database &lt;/li&gt;
&lt;li&gt;Build the CRUD (Create Read Update Delete) and confirm it is working via Postman&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before the instructions begin, Here's a little background for the things mentioned above in case you are new to this. Otherwise feel free to skip below to the steps. &lt;/p&gt;

&lt;h2&gt;
  
  
  Baseline knowledge:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is an API or “Application Programming Interface”?&lt;/strong&gt;&lt;br&gt;
When I was brand new to this, knowing the abbreviation didn't really clarify things for me. Instead I tried to understand it via metaphors. &lt;/p&gt;

&lt;p&gt;An API is the 'middle person' between the front end (web page that user sees and interacts with) and the backend (where the database is). The API allows the front and back end to communicate back and forth. &lt;/p&gt;

&lt;p&gt;A common metaphor you can use to understand the use of an API is to think of a waiter at a restaurant. They take your request or order for food and deliver that request to the cook. Then the waiter brings you back the specified food. Similarly, an API takes a request from a client (user) and gives it to the backend for processing (the cook). The backend returns the request to the user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is CRUD?&lt;/strong&gt; &lt;br&gt;
Continuing with the waiter metaphor, a waiter has multiple tasks they can perform. Those tasks can include getting a menu, updating the cook if you want to alter your order, bring your meal out, or even telling the cook you no longer want something. &lt;/p&gt;

&lt;p&gt;With this in mind, there are certain core tasks that an API should do and it is abbreviated as CRUD. As long as an API can do these four things, it is considered a RESTful API which is the standard for a good functional website:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create&lt;/strong&gt;: create a new item in the database&lt;br&gt;
&lt;strong&gt;Read&lt;/strong&gt;: display or return existing item/s from the database&lt;br&gt;
&lt;strong&gt;Update&lt;/strong&gt;: change an existing item in the database&lt;br&gt;
&lt;strong&gt;Delete&lt;/strong&gt;: remove an existing item from the database &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is NodeJS?&lt;/strong&gt;&lt;br&gt;
It is a Javascript based software that can be used to create applications. In the case of this tutorial, it is used to create the REST API server. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is PostgresSQL?&lt;/strong&gt;&lt;br&gt;
This is a relational database system. It will hold all the tables and schemas for the website. For example, it will hold the both the template and the actual data for a user’s username, email, and password. &lt;/p&gt;

&lt;p&gt;Now that the basic idea has been explained, we can now set up our NodeJS API. &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1 -Set up NodeJS-
&lt;/h2&gt;

&lt;p&gt;A. Download and install &lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;NodeJS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;B. Confirm successful installation by typing &lt;code&gt;node -v&lt;/code&gt; in the terminal &lt;/p&gt;

&lt;p&gt;C. In the folder containing your project, create a new folder called &lt;code&gt;bird_banders_api&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;D. To create the NodeJS API, &lt;code&gt;cd&lt;/code&gt; into this new folder and write &lt;code&gt;npm init -y&lt;/code&gt; in the terminal. The &lt;code&gt;-y&lt;/code&gt; is so that it doesn’t ask a bunch of questions and just creates the default settings for us. &lt;/p&gt;

&lt;p&gt;E. Now there's several NPM packages to install, they can be written all on one line: &lt;code&gt;npm i express pg cors&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The server is through Express, PG connects NodeJS to the database, and CORS allows for domains to interact with each other.&lt;/p&gt;

&lt;p&gt;F. To allow the server to automatically display code changes (rather than having to start and stop the server all the time), in your terminal write &lt;code&gt;npm i -D nodemon&lt;/code&gt;. The &lt;code&gt;-D&lt;/code&gt; is because we only need this installation applied to our development environment, not for the deployed site.&lt;/p&gt;

&lt;p&gt;Here is an example of how the terminal should look thus far: &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%2Fi%2F8r9n27z5ljs3n2y5d8xn.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%2Fi%2F8r9n27z5ljs3n2y5d8xn.png" alt="Shows all above steps in terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;G. Once this is done, if you have Zsh installed, you can type &lt;code&gt;code .&lt;/code&gt; in the terminal and it will open the api project in vscode. Otherwise, open the project however you want. The side bar should look like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqeat5mhdehxyvws14s40.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%2Fi%2Fqeat5mhdehxyvws14s40.png" alt="vscode side bar shows bird_banders_api with node_modules, json package, and json lock file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;H. To create a file that will handle all the functions of the API. In the terminal write, &lt;code&gt;touch index.js&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fim3ln24nj96yqvo40qth.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%2Fi%2Fim3ln24nj96yqvo40qth.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I. We also need some convenient terminal commands for starting the server. Go to &lt;code&gt;package.json&lt;/code&gt; and edit the scripts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "node server.js",
"dev": "nodemon server.js"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what the &lt;code&gt;package.json&lt;/code&gt; file should look like now: &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%2Fi%2Ftp4jbk7bbim3kn5zw17v.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%2Fi%2Ftp4jbk7bbim3kn5zw17v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;J. In order to start using express (our server) add these lines of code to &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// pulls in the express library
const express = require('express')

// allows us to write app and the crud action we want ex. app.get | app.post | app.delete etc...
const app = express()
const cors = require('cors')

// middleware
app.use(express.json()) // =&amp;gt;  allows us to read the request or req body
app.use(cors())

// Routes (to be filled out later in tutorial)


// define what localhost port we want our server to run on
app.listen(3000, ()=&amp;gt; {
    console.log(`Server running on port: 3000`)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fi%2Fb78mfqs6hfwcn71ww91c.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%2Fi%2Fb78mfqs6hfwcn71ww91c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;K. From here on out, you can now type: &lt;code&gt;npm run dev&lt;/code&gt; to start the backend server. In your console, you should see:&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%2Fi%2Fr9s8ky8hicxv7hri2oz3.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%2Fi%2Fr9s8ky8hicxv7hri2oz3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have now completed the NodeJS set up! Now we’ll create the database. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 -Set up the Postgres Database-
&lt;/h2&gt;

&lt;p&gt;A. There are multiple ways to install Postgres, for me I did it through Mac’s &lt;a href="https://brew.sh/" rel="noopener noreferrer"&gt;Brew software&lt;/a&gt;. If you don’t have brew, you can install it by pasting this in the terminal: &lt;br&gt;
&lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;B. To install Postgres, in the terminal type: &lt;br&gt;
&lt;code&gt;brew install postgresql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;C. Connect to postgres with: &lt;br&gt;
&lt;code&gt;psql -U postgres&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; &lt;br&gt;
&lt;code&gt;psql&lt;/code&gt; tells the terminal to start the postgres command line. &lt;br&gt;
&lt;code&gt;-U&lt;/code&gt; means we are about to specify which user we want to use. &lt;br&gt;
Postgres is the default superuser name, and a superuser means you don’t have any limitations on manipulating databases. &lt;/p&gt;

&lt;p&gt;So the above essentially means: start the psql command line through the superuser that is named “postgres”.&lt;/p&gt;

&lt;p&gt;D. If you do not have 'postgres' as a superuser, you can create the superuser 'postgres' by pasting this into your terminal. Note the &lt;code&gt;;&lt;/code&gt;, it won't work if you forget to include it in the second command: &lt;code&gt;psql&lt;/code&gt;&lt;br&gt;
then: &lt;code&gt;CREATE USER postgres SUPERUSER;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;E. Once you are in the psql command line, add:&lt;br&gt;
&lt;code&gt;CREATE DATABASE bird_banders;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We now have our database! &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%2Fi%2Fwupszublz9muibbfskmr.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%2Fi%2Fwupszublz9muibbfskmr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some commands to familiarize with for Postgres:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;\l&lt;/code&gt; will show you the list of databases you’ve created so far including the one you just created:&lt;/li&gt;
&lt;/ul&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%2Fi%2Fkseyuu8ycs7jv2j2cs3d.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%2Fi%2Fkseyuu8ycs7jv2j2cs3d.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;\c bird_banders&lt;/code&gt; connects you to that database, so we can add tables to it. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;\dt&lt;/code&gt; will show us that we don’t have anything set up yet, but in the future this command will show us the tables we have.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;F. Connect to the database now by pasting this into the terminal: &lt;code&gt;\c bird_banders&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;G. Create a table in the database... &lt;/p&gt;

&lt;p&gt;Click on summary if you want a beginner's explanation on databases. If not, just keep reading ahead to see the steps. &lt;br&gt;

  summary
  &lt;br&gt;
&lt;strong&gt;Using tables in databases&lt;/strong&gt;&lt;br&gt;
Tables are a series of rows and columns that contain data. If we have many tables, they can all relate to each other to make way for more complex and organized data. 

&lt;p&gt;For example, a table could contain a list of people who own pets. This people list contains data for people’s names, location, and pets. Then another table that just contains a list of pets has the pet’s name, age, and species. &lt;/p&gt;

&lt;p&gt;Since each person and each animal is on a different table, we give each of them an ID number. So on the owner’s table, let’s say Bob has 3 cats. Instead of listing out each cat on the owner’s table, we just list out the three unique IDs of the cats. Postgres will then be able to pull up all the information about those three cats on the pet table. It’s essentially like a “separation of concerns” for data. &lt;br&gt;
&lt;/p&gt;

&lt;br&gt;
&lt;br&gt;&lt;br&gt;
... For my bird banding project, I want to start off with something simple. There will be individual organizations who use the website, so I need a table to keep track of their names. In future tutorials, the database will grow more complex, but for now we’ll just stick with this. I have refrained from using “group” for the table name because group is a reserved word in Postgres, meaning it may refuse to create the table since group can used as a command or cause bugs later.&lt;/p&gt;

&lt;p&gt;H. Enter the following code into the terminal to create the table (I have shortened “organization” to “org”):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE org(
    org_id SERIAL PRIMARY KEY,
    name VARCHAR(100)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;SERIAL PRIMARY KEY&lt;/code&gt; tells Postgres to make a unique ID number for each organization. &lt;code&gt;Name VARCHAR(100)&lt;/code&gt; tells Postgres that each org will have a name attribute and that it shouldn’t exceed 100 characters in length. &lt;/p&gt;

&lt;p&gt;I. When &lt;code&gt;\dt&lt;/code&gt; is typed into the terminal, we can see our database now has a table. The below image show what the terminal should look like after following steps F through I:&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%2Fi%2Ffgr8ksvq3dm972jjdnvc.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%2Fi%2Ffgr8ksvq3dm972jjdnvc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;J. This newly created database now needs to be connected to the nodeJS server. Press &lt;code&gt;ctrl&lt;/code&gt; + &lt;code&gt;d&lt;/code&gt; to get out of Postgres in the terminal and go back to the nodeJS project in VScode. Write &lt;code&gt;touch db.js&lt;/code&gt; to create a file to hold the database settings.&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%2Fi%2Fce4thyo4pbdky4cj4h6r.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%2Fi%2Fce4thyo4pbdky4cj4h6r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;K. Inside of &lt;code&gt;db.js&lt;/code&gt; we’ll add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Pool = require('pg').Pool

const pool = new Pool({
    user: 'postgres',
    password: '',
    database: 'bird_banders',
    host: 'localhost',
    port: 5432
})

module.exports = pool;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
Earlier in the tutorial we installed &lt;code&gt;pg&lt;/code&gt; which is a library that allows Postgres and NodeJS to connect. Pool contains all the information that nodeJS needs to communicate with the database. The &lt;code&gt;5432&lt;/code&gt; port is the default for Postgres. Lastly, we export this as a module so that we can actively use it in our main file, &lt;code&gt;index.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;L. In &lt;code&gt;index.js&lt;/code&gt;, add under the other requires: &lt;br&gt;
&lt;code&gt;const pool = require('./db')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is what it should look like so far: &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%2Fi%2Fop98hji4v9uv56rvch7h.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%2Fi%2Fop98hji4v9uv56rvch7h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can finally get to the CRUD!&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3 -Build the CRUD-
&lt;/h2&gt;

&lt;p&gt;Each of the CRUD operations follow a similar formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.action(‘route path’, async (req, res) =&amp;gt; {
    try {
        const data_we_want = await pool.query(“postgres commands”)
        res.json(data_we_want)
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app.action&lt;/code&gt; could be &lt;code&gt;app.&lt;/code&gt; &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;post&lt;/code&gt;, &lt;code&gt;put&lt;/code&gt;, or &lt;code&gt;delete&lt;/code&gt;. We’ll be doing one of each. &lt;/p&gt;

&lt;p&gt;There are two arguments that go into the &lt;code&gt;app.action&lt;/code&gt;. The first is the route path, in the current case, it’ll be &lt;code&gt;/orgs&lt;/code&gt; since that’s the table we’ve created. &lt;/p&gt;

&lt;p&gt;The second argument is a function that will process data. Think inception… because this function also takes in two arguments. They are the &lt;code&gt;request&lt;/code&gt; and the &lt;code&gt;response&lt;/code&gt; for the data (think back to the waiter analogy as well).  It is like this function is taking in the order for your meal and will output that meal once the chef has prepared it. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;try&lt;/code&gt; and &lt;code&gt;catch&lt;/code&gt; is a handy way to execute a block of code, but also have a backup action if that block of code fails. In order to use this though, we have to make the function asynchronous or put the &lt;code&gt;async&lt;/code&gt; label in front of it and the &lt;code&gt;await&lt;/code&gt; in front of the query. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;try&lt;/code&gt; is where you put the block of code you want to attempt. &lt;code&gt;catch&lt;/code&gt; is what will execute if that block code fails.      &lt;/p&gt;

&lt;p&gt;With repetition this will start to make more sense. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Create action&lt;/strong&gt;&lt;br&gt;
The create action allows the front end user to create an organization with a name. This would usually be submitted by a front-end user. This new incoming information is contained in a request or &lt;code&gt;req&lt;/code&gt; (think about the waiter metaphor.. requesting a food order to a waiter). &lt;/p&gt;

&lt;p&gt;Paste this code in your routes section in &lt;code&gt;index.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// create an org
app.post('/orgs', async (req, res) =&amp;gt; {
    try {
        // await
        console.log(req.body)
        const { name } = req.body
        const newOrg = await pool.query(
            "INSERT INTO org (name) VALUES ($1) RETURNING *", // returning * lets us see the data in the json response
            [name]
        ) 
        res.json(newOrg.rows[0])
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;index.js&lt;/code&gt; page should look like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqbvjy5uv9omsyax2j8oi.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%2Fi%2Fqbvjy5uv9omsyax2j8oi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
The route is &lt;code&gt;/orgs&lt;/code&gt; because that’s the name of the table we want to interact with. &lt;/p&gt;

&lt;p&gt;If we had a user table (which we will go over in a future tutorial), then the route to create a new user would be &lt;code&gt;/users&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;try&lt;/code&gt; block, we only want to grab the actual name of the organization from &lt;code&gt;req&lt;/code&gt;, which is inside the req’s &lt;code&gt;body&lt;/code&gt;. Destructuring the name out of the body makes the code look cleaner. &lt;/p&gt;

&lt;p&gt;Once the organization’s name is pulled out of the request, that data must be sent to the org table in the database and a new organization must be created:&lt;br&gt;
&lt;code&gt;“INSERT INTO org (name) VALUES ($1) RETURNING *", [name])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$1&lt;/code&gt; sign is just a variable placeholder in the first argument and the second argument &lt;code&gt;[name]&lt;/code&gt; is the value that will be inserted into where &lt;code&gt;$1&lt;/code&gt; resides in the Postgres command. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;RETURNING *&lt;/code&gt; lets us see the data in the json response (for example if you are using Postman).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Postman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the link to &lt;code&gt;http://localhost:3000/orgs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select POST (dropdown menu to the left of the link)&lt;/li&gt;
&lt;li&gt;Select 'Body'&lt;/li&gt;
&lt;li&gt;Make sure 'raw' is selected as well as 'JSON' (next to where it says 'GraphQL')&lt;/li&gt;
&lt;li&gt;Type some incoming data:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "name": "Bird Group" 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Press the blue send button to see the results. If successful it should say in the lower half of the screen:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "org_id": 1,
    "name": "UTD Birding"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fi%2F5l5zwfza6apwqf6qef8s.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%2Fi%2F5l5zwfza6apwqf6qef8s.png" alt="Image of postman explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Read action&lt;/strong&gt;&lt;br&gt;
The read action for seeing all organizations in the database is one of the easiest actions. And now that we can add some names with the create action, we can actually see some these new orgs by using the read action. Below the create action, paste in this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// get all orgs
app.get('/orgs', async (req, res) =&amp;gt; {
    try {
        const allOrgs = await pool.query("SELECT * FROM org")
        res.json(allOrgs.rows)
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
The &lt;code&gt;*&lt;/code&gt; means all, so the query is saying select all items from the org table. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;res.json(newOrg.rows[0])&lt;/code&gt; sends back (can see on postman) the new information that was generated. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Postman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure the link is still &lt;code&gt;http://localhost:3000/orgs&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select GET to the left of the link&lt;/li&gt;
&lt;li&gt;Press the blue send button to see the results. If successful you should now see a list of organizations in your database. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C. Read action 2&lt;/strong&gt;&lt;br&gt;
The second most common read action is when you want to only get one organization from the table instead of the whole list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// get only one organization
app.get('/orgs/:id', async (req, res) =&amp;gt; {
    console.log(req.params)
    const { id } = req.params
    try {
        const org = await pool.query("SELECT * FROM org WHERE org_id = $1", [id]) 
        // $1 is a placeholder, then the 2nd argument is what that variable is 
        //going to be
        res.json(org.rows[0])
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
It is pretty much the same thing as the previous read action, only this time we need one extra thing for it to work. Remember how each organization in the table has a unique ID attached to it? Well, we can grab that from the &lt;code&gt;req.params&lt;/code&gt;. And we add the id to the route path &lt;code&gt;/orgs&lt;/code&gt; + &lt;code&gt;/:id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Postman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add an ID number to the end of the url:  &lt;code&gt;http://localhost:3000/orgs/2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select GET to the left of the link&lt;/li&gt;
&lt;li&gt;Press the blue send button to see the results. If successful you should now see the organization that is associated with with that ID number.&lt;/li&gt;
&lt;/ul&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%2Fi%2F9y9oz2h4z8c120b0u1ba.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%2Fi%2F9y9oz2h4z8c120b0u1ba.png" alt="Postman get one organization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D. Update action&lt;/strong&gt;&lt;br&gt;
The update action is one of the more complex actions. It is very similar to our previous action of getting only one organization. We need the ID number in order to know which organization in the table to update. We then need to grab the updated information from the &lt;code&gt;req.body&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// update an organization
app.put('/orgs/:id', async (req, res) =&amp;gt; {
    try {
        const { id } = req.params // where
        const { name } = req.body // grab the new info
        const updateOrg = await pool.query(
            "UPDATE org SET name = $1 WHERE org_id = $2", [name, id]
        )
        res.json('The organization name was updated')
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;"UPDATE org SET name = $1 WHERE org_id = $2", [name, id]&lt;/code&gt;&lt;br&gt;
The query is saying:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;UPDATE&lt;/code&gt; at the &lt;code&gt;org&lt;/code&gt; table. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SET&lt;/code&gt; the &lt;code&gt;name&lt;/code&gt; of the organization &lt;code&gt;WHERE&lt;/code&gt; &lt;code&gt;org_id&lt;/code&gt; matches the variable &lt;code&gt;$2&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;There are two variables needed for this, the &lt;code&gt;name&lt;/code&gt; hence the &lt;code&gt;$1&lt;/code&gt; and the &lt;code&gt;id&lt;/code&gt; hence the &lt;code&gt;$2&lt;/code&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;res.json&lt;/code&gt; line is to return to the user a message that the update was successful. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Postman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the ID number of the organization you want to update. If you are unsure which to choose, try performing a GET in Postman first.
&lt;code&gt;http://localhost:3000/orgs/1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select PUT to the left of the link&lt;/li&gt;
&lt;li&gt;Press the blue send button to see the results. If successful you should now see a message saying "The organization name was updated".&lt;/li&gt;
&lt;/ul&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%2Fi%2Fco80ief1axuvzajj8y3r.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%2Fi%2Fco80ief1axuvzajj8y3r.png" alt="Image of an update in Postman"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Delete action&lt;/strong&gt;&lt;br&gt;
We’ve finally reached the last action! This one is pretty straightforward. Once again, we need to grab the ID so we know which organization to delete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// delete an org
app.delete('/orgs/:id', async (req, res) =&amp;gt; {
    try {
        const { id } = req.params
        const deleteOrg = await pool.query(
            "DELETE FROM org WHERE org_id = $1", [id]
        )
        res.json('The organization was deleted')
    } catch (err) {
        console.error(err.message)
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;"DELETE FROM org WHERE org_id = $1", [id])&lt;/code&gt;&lt;br&gt;
For the query it means &lt;code&gt;DELETE FROM&lt;/code&gt; the &lt;code&gt;org&lt;/code&gt; table &lt;code&gt;WHERE&lt;/code&gt; the &lt;code&gt;org_id&lt;/code&gt; matches the &lt;code&gt;$1&lt;/code&gt; variable, which is set to &lt;code&gt;[id]&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Postman:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the ID number of the organization you want to update. If you are unsure which to choose, try performing a GET in Postman first.
&lt;code&gt;http://localhost:3000/orgs/1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select DELETE to the left of the link&lt;/li&gt;
&lt;li&gt;Press the blue send button to see the results. If successful you should now see a message saying "The organization was deleted".&lt;/li&gt;
&lt;/ul&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%2Fi%2Fc7sps1t6iln67t43nts2.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%2Fi%2Fc7sps1t6iln67t43nts2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So with that, you should now know how to set up your backend!&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>node</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Build a Website Series Part 1: Set up React with Routes and Navbar</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Mon, 14 Sep 2020 20:31:32 +0000</pubDate>
      <link>https://forem.com/wolfdominion/build-a-website-series-part-1-set-up-react-with-routes-and-navbar-la2</link>
      <guid>https://forem.com/wolfdominion/build-a-website-series-part-1-set-up-react-with-routes-and-navbar-la2</guid>
      <description>&lt;p&gt;Hey all, I am going to rebuild one of my bootcamp projects from the ground up now that I have better fullstack development skills. I am documenting the steps for making a fully functional and deployed site. &lt;/p&gt;

&lt;p&gt;If you want to follow along, here is what you need to know:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before starting:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The tech stack is React and Node.js, so make sure you install these on your computer. I use VS Code and work on a Mac (though these steps should still work on a PC). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/getting-started.html" rel="noopener noreferrer"&gt;Install React&lt;/a&gt;&lt;br&gt;
&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Install Node.js&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This tutorial also requires you be familiar with using your command line/terminal. If you are unsure about this, try searching for tutorials on how to use this. I have Zsh installed for my terminal, so keep that in mind when viewing some of this tutorial's screenshots. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here is my &lt;a href="https://github.com/wolf-dominion/bird_banders_2.0" rel="noopener noreferrer"&gt;repo&lt;/a&gt; for this project&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What Part 1 covers:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a new React project that includes packages for this specific project&lt;/li&gt;
&lt;li&gt;Link the new project to a Github repo&lt;/li&gt;
&lt;li&gt;Create simple pages as React components &lt;/li&gt;
&lt;li&gt;Add routes(links) to these pages&lt;/li&gt;
&lt;li&gt;Add a styled and functional Navbar to site&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  Step 1 -Create project and add packages-
&lt;/h2&gt;

&lt;p&gt;A. Open the terminal inside of VS Code and make sure you are in the correct folder where you want to create the project (Type in &lt;code&gt;ls&lt;/code&gt; to help see which folder you're in)&lt;/p&gt;

&lt;p&gt;B. Create the React project. The last part shown below is the title of the project, so you don't have to type in "bird-banders" but it may make it easier to follow along in later steps if you follow my file names. In the terminal type: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app bird_banders&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;C. &lt;code&gt;cd&lt;/code&gt; into the new react project &lt;/p&gt;

&lt;p&gt;D. At this point, at any time you can run the site on your local host by typing &lt;code&gt;npm start&lt;/code&gt; or &lt;code&gt;yarn start&lt;/code&gt; in the terminal &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary of commands:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app bird_banders
cd bird_banders
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E. This React project needs some additional packages for the features in this tutorial. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/react-router-dom" rel="noopener noreferrer"&gt;React-Router-Dom&lt;/a&gt; is needed to create navigable pages (and will later allow us to have protected pages that can only be viewed by logging in). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://react-bootstrap.github.io/getting-started/introduction" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt; is needed to give us some default styling to the website that would otherwise take hours and higher level skills. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://create-react-app.dev/docs/adding-a-sass-stylesheet/" rel="noopener noreferrer"&gt;Sass Styling&lt;/a&gt; makes styling so much easier and cleaner. Sass also allows us to easily import Bootstrap's styling into the project. &lt;/p&gt;

&lt;p&gt;In your terminal in the project type: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save react-router-dom&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install react-bootstrap bootstrap&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install node-sass --save&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example of what it should look like: &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%2Fi%2Fwe3rrs6kjlw5o42rcy98.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%2Fi%2Fwe3rrs6kjlw5o42rcy98.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;F. Inside of src folder, rename App.css to App.scss and in this file add at the top: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;@import 'node_modules/bootstrap/scss/bootstrap'; // existing bootstrap import&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You may need to type &lt;code&gt;npm run build&lt;/code&gt; in order for React to put all this together. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 -Set up Github repo-
&lt;/h2&gt;

&lt;p&gt;A. It is important to set up a remote repo for backup and tracking your code changes and implementations. It is very simple, if you already have an account just go to: &lt;a href="https://github.com/new" rel="noopener noreferrer"&gt;https://github.com/new&lt;/a&gt;&lt;br&gt;
Otherwise, make an account first then go to the above link. &lt;/p&gt;

&lt;p&gt;B. React automatically creates a local repo, so to add it to GitHub, just follow these steps (but with your own link) in your VS Code terminal:&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%2Fi%2Fv50hx87u8uzty5gcyzdl.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%2Fi%2Fv50hx87u8uzty5gcyzdl.png" alt="Github push repo from command line instructions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On a side note, its been a while since I linked my github account with my terminal, so if you've never set that up before, you may have to do some additional steps on your terminal&lt;/p&gt;

&lt;p&gt;C. Go to the GitHub project page to make sure your local project successfully saved to Github&lt;/p&gt;

&lt;p&gt;D. To begin coding, in your VS Code terminal open the react project folder. Since I have Zsh installed, I just type &lt;code&gt;code .&lt;/code&gt; in the terminal&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%2Fi%2F5sg35u02fyjw022cbstd.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%2Fi%2F5sg35u02fyjw022cbstd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the sidebar in VS Code should look like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1yungs8blg6mj8swu9hd.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%2Fi%2F1yungs8blg6mj8swu9hd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3 -Create simple pages as React components-
&lt;/h2&gt;

&lt;p&gt;A. You may have noticed that if you start the server, there is a default React page with a rotating icon. I like to start with a clean slate, so open the &lt;code&gt;App.js&lt;/code&gt; file and we'll remove the unnecessary lines, so it should 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;import React from 'react';

function App() {
  return (
    &amp;lt;div&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B. When I build a somewhat complex site I organize a &lt;a href="https://docs.google.com/document/d/1mWQWo1Llm3V848zoI0jZBtQqmGjqsJqrmZDVn9kTE3k/edit?usp=sharing" rel="noopener noreferrer"&gt;design document&lt;/a&gt; and sketch in a notebook. I have a list of core functionalities the site needs and like to start off with a basic navigable site. After that I fill in each page and functionality. I’ve decided to implement the navbar and routes first. &lt;/p&gt;

&lt;p&gt;Note- the design doc is not complete. I just add as I go but it helps me get a sense for what all needs to be done and it can give you an idea of what tutorials will happen in the future. &lt;/p&gt;

&lt;p&gt;C. For the first pages let’s start with:&lt;/p&gt;

&lt;p&gt;Home&lt;br&gt;
UserProfile&lt;br&gt;
Organization&lt;br&gt;
Organizations&lt;/p&gt;

&lt;p&gt;Right click &lt;code&gt;src&lt;/code&gt; and add new folder called &lt;code&gt;pages&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;D. Inside of the &lt;code&gt;pages&lt;/code&gt; folder, create new js files with the names of your pages (listed above). When you're done the sidebar should have this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmjeth2ursuod5ryzc73u.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%2Fi%2Fmjeth2ursuod5ryzc73u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;E. Fill in the base code for each component, since they’re all pages they’ll be pretty similar. I am using hooks for this project, so we will not be using classes, but rather functional components. Below is what each page component contains, just make sure to name the function and export correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

function Home() {
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;p&amp;gt;Home page&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}

export default Home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4 -Add routes(links) to pages-
&lt;/h2&gt;

&lt;p&gt;A. Now that the pages exist, we want to be able to actually see these pages in the browser and ideally with the correct url. An easy way to do this is by adding Routes via the React-Router-Dom package. To do this, open &lt;code&gt;App.js&lt;/code&gt; and starting on line 2 add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {BrowserRouter as Router, Route} from 'react-router-dom'

import Home from './pages/Home';
import Organization from './pages/Organization';
import Organizations from './pages/Organizations';
import UserProfile from './pages/UserProfile';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B. Now we've essentially 'activated' the router functionality and imported each page into the app. Now we want to be able to render the pages. Inside of return (which is where things get rendered), add the Router component like so: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Router&amp;gt;&amp;lt;Router/&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;C. Inside of the Router component, add each page route. The general pattern is:&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;Route path='pathname'&amp;gt;
    &amp;lt;Name of page component/&amp;gt;
&amp;lt;Route /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And make sure to only ever have ONE Router component. You can have many routes, but only one Router. &lt;/p&gt;

&lt;p&gt;The end result for &lt;code&gt;App.js&lt;/code&gt; should 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;import React from 'react';
import {BrowserRouter as Router, Route} from 'react-router-dom'

import Home from './pages/Home';
import Organization from './pages/Organization';
import Organizations from './pages/Organizations';
import UserProfile from './pages/UserProfile';

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;Route exact path='/'&amp;gt;
        &amp;lt;Home/&amp;gt;
      &amp;lt;/Route&amp;gt;
      &amp;lt;Route path='/organization'&amp;gt;
        &amp;lt;Organization/&amp;gt;
      &amp;lt;/Route&amp;gt;
      &amp;lt;Route path='/organizations'&amp;gt;
        &amp;lt;Organizations/&amp;gt;
      &amp;lt;/Route&amp;gt;
      &amp;lt;Route path='/UserProfile'&amp;gt;
        &amp;lt;UserProfile/&amp;gt;
      &amp;lt;/Route&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, as long as you type in the /pagename on your browser, you should see the correct component. &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%2Fi%2Fkfobluyaks5fls7is5kl.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%2Fi%2Fkfobluyaks5fls7is5kl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, that’s obviously not an ideal way to navigate through a site, hence the navbar is needed. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5 -Navbar-
&lt;/h2&gt;

&lt;p&gt;A. We are on the home stretch for this tutorial! Adding the navbar is pretty easy. Within &lt;code&gt;src&lt;/code&gt;, create a new folder called &lt;code&gt;ui-components&lt;/code&gt;, and inside that create a js file called &lt;code&gt;Header&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Here is what the sidebar should look like now: &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%2Fi%2Fnfqklk1ia24244mmnsiv.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%2Fi%2Fnfqklk1ia24244mmnsiv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;B. This &lt;a href="https://react-bootstrap.github.io/components/navbar/" rel="noopener noreferrer"&gt;Bootstrap navbar&lt;/a&gt; page can help you learn more about how they work. I am only including &lt;code&gt;Home&lt;/code&gt; and &lt;code&gt;Organizations&lt;/code&gt; in the navbar. This is what the &lt;code&gt;Header&lt;/code&gt; component contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import { Nav, Navbar } from "react-bootstrap";
import { Link } from 'react-router-dom'

function Header() {
    return(
        &amp;lt;Navbar className="w-auto p-3 fixed-top" collapseOnSelect expand="lg" bg="dark" variant="dark"&amp;gt;
            &amp;lt;Navbar.Brand as={Link} to="/"&amp;gt;BirdBanders&amp;lt;/Navbar.Brand&amp;gt;
            &amp;lt;Navbar.Toggle aria-controls="responsive-navbar-nav" /&amp;gt;
            &amp;lt;Navbar.Collapse id="responsive-navbar-nav"&amp;gt;
                &amp;lt;Nav className="mr-auto"&amp;gt;

                &amp;lt;/Nav&amp;gt;
                &amp;lt;Nav&amp;gt;
                &amp;lt;Nav.Link as={Link} to="/"&amp;gt;Home&amp;lt;/Nav.Link&amp;gt;
                &amp;lt;Nav.Link as={Link} to="Organizations"&amp;gt;Organizations&amp;lt;/Nav.Link&amp;gt;
                &amp;lt;/Nav&amp;gt;
            &amp;lt;/Navbar.Collapse&amp;gt;
        &amp;lt;/Navbar&amp;gt;
    )
}

export default Header
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C. Put the header in the app. To do this, inside of &lt;code&gt;App.js&lt;/code&gt; near the top add: &lt;code&gt;import Header from './ui-components/Header';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;D. Inside of &lt;code&gt;App.js&lt;/code&gt; in the Router component, put &lt;code&gt;&amp;lt;Header/&amp;gt;&lt;/code&gt; at the top. Since it should be on every page, it does not go inside of a Route component.&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;Router&amp;gt;
      &amp;lt;Header/&amp;gt;
      &amp;lt;Route exact path='/'&amp;gt;
        &amp;lt;Home/&amp;gt;
      &amp;lt;/Route&amp;gt;
etc...
&amp;lt;Router /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E. The very last thing is to fix how the navbar is covering the top of each page, and thus covering the page titles in the browser. In &lt;code&gt;App.js&lt;/code&gt;, surround the &lt;code&gt;&amp;lt;Header /&amp;gt;&lt;/code&gt; component with a div. Add a &lt;code&gt;className&lt;/code&gt; of &lt;code&gt;navbar&lt;/code&gt; to it.&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 className='navbar'&amp;gt;
  &amp;lt;Header/&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;F. In App.scss and add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.navbar {
  padding-bottom: 69px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome... now everything should be in working order! You now have a React website with pages and a working navbar. Consider this a massive playground now for you to experiment with. &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%2Fi%2F65i000a7lchtepmi0ff1.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%2Fi%2F65i000a7lchtepmi0ff1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know how this tutorial was or any questions/comments you have. Next up will be setting up the backend. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/wolfdominion/build-a-pern-website-part-2-nodejs-crud-api-with-postgres-57ma"&gt;Next tutorial &amp;gt;&amp;gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>design</category>
    </item>
    <item>
      <title>Introduction to TDD: What it is and why it is important</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Tue, 04 Aug 2020 21:32:56 +0000</pubDate>
      <link>https://forem.com/wolfdominion/introduction-to-tdd-what-it-is-and-why-it-is-important-2hhf</link>
      <guid>https://forem.com/wolfdominion/introduction-to-tdd-what-it-is-and-why-it-is-important-2hhf</guid>
      <description>&lt;p&gt;Many companies today are using test driven development or TDD to create their web software. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why is test driven development so important?
&lt;/h2&gt;

&lt;p&gt;TDD has become very popular because it prevents issues and bugs in the future, it can increase the efficiency of your work flow, and help teams communicate the intentions of their code's functionality. A downside of TDD is that it takes longer to get a project started, so it requires a little bit of up-front patience. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The basic flow of TDD&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a test (make sure it fails so you don't get a false positive)&lt;/li&gt;
&lt;li&gt;Write code to try to pass the test&lt;/li&gt;
&lt;li&gt;Once passing, refactor where possible in both test and implementation code&lt;/li&gt;
&lt;li&gt;Create the next test and repeat&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Concepts to keep in mind while creating tests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Readable&lt;/strong&gt; -&amp;gt; Make it clear what the test's actual and expected behavior is, and why.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isolated&lt;/strong&gt; -&amp;gt; Make sure tests only cover a particular segment of code, because you don't want certain tests interfering with other tests. If interference occurs, you may not know if the test failed due to your target code or from a previous test. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thorough&lt;/strong&gt; -&amp;gt; Prepare for edge cases, like if someone enters in something totally unrelated to the expected input. For example, what if someone tries to submit an empty form? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explicit&lt;/strong&gt; -&amp;gt; This ties in with code readability. If someone looks at the test, they should be able to require little setup. &lt;/p&gt;

&lt;h2&gt;
  
  
  The 3 main types of tests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Unit test&lt;/strong&gt; -&amp;gt; small pieces of functionality &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration test&lt;/strong&gt; -&amp;gt; checking if all the smaller tests/code work together such as seeing if the app communicates with an API (Application programming interface) correctly&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End-to-End&lt;/strong&gt; -&amp;gt; tests entire application from user viewpoint (examples: Selenium or Cypress.io)&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;(usually in the form of libraries)&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Testing environment/test runner (the place to run tests)&lt;/li&gt;
&lt;li&gt;Testing framework (Ex. Mocha or Jasmine, organizes/holds your test code)&lt;/li&gt;
&lt;li&gt;An assertion library (this allows you to not have to write tons of if-statements, this does the actual verifications of test results)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Sources:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://www.linkedin.com/learning/javascript-test-driven-development-es6"&gt;https://www.linkedin.com/learning/javascript-test-driven-development-es6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/25678063/whats-the-difference-between-assertion-library-testing-framework-and-testing-e"&gt;https://stackoverflow.com/questions/25678063/whats-the-difference-between-assertion-library-testing-framework-and-testing-e&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>tdd</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What I Learned About Attitude and Mindset in Coding Bootcamp Pt. 2</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Thu, 02 Jul 2020 18:44:50 +0000</pubDate>
      <link>https://forem.com/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-2-2keh</link>
      <guid>https://forem.com/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-2-2keh</guid>
      <description>&lt;p&gt;This is my second post out of a three part series regarding attitudes and approaches to healthily get through a coding bootcamp. Aside from learning to temper my hyper-focus on competition, I’ve also learned that self care is not something to ignore or avoid.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self Care is mandatory&lt;/strong&gt;&lt;br&gt;
Pace, balance, rest, and understanding… all of these things contribute to the concept of self care. Think of someone who you care deeply about; for me it would be my future son or daughter. Now, take a look at the way you run your life and the way you treat yourself. Would you want that for them? Would I want my daughter to work an average of 12 hours a day on code and then feel afterwards like she was a total failure and not good enough? Of course not. Sometimes when we step out of our shoes, we can see the absurdity of the expectations we hold for ourselves. Not only is it absurd, but it is not sustainable to ignore other facets of life that make things meaningful. Each one of us is valuable and worthy of self care. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;I got super into the flow of coding during the bootcamp, and in the moment I was like, “I’m not gonna stop until I have everything working!” It was an addictive flow. However, day after day of doing this, I started having focusing and memory problems. I also couldn’t sleep properly because my mind was literally still trying to code in a half dream state. It got to the point where I was forgetting to eat, drink, and get up to go to the bathroom. I started to feel mildly insane. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Improvement&lt;/strong&gt; &lt;br&gt;
Then I realized that I was essentially marathoning. In an actual marathon, you run just over 26 miles. Even if you love coding, even if you love running, no one is going to thrive if they keep working at maximum capacity. I felt guilty initially when I took breaks, like “oh I could be learning more about enumerables right now instead of laying in bed”, but then I had an attitude shift to, “I feel guilty about not taking care of myself properly.” Would you feel badly towards someone who just ran a marathon and they’re asking for a break?&lt;/p&gt;

&lt;p&gt;This brings in the concept of pacing. It is easier on the body to run a few miles per day rather than doing it all in one session. Same with the brain. Even though I have the &lt;em&gt;capacity&lt;/em&gt; to marathon the project, that’s probably not what I &lt;em&gt;should&lt;/em&gt; do. Eventually, I discovered what works best for me: I code 9am-12 noon. Take a yoga and lunch break. Then 1-5pm do more code. Afterwards, I play board games with friends, work on art, and exercise outside (and sometimes splurge on Netflix or Youtube). When I pace it out, it is absolutely amazing how my mind feels so much better. More focus, less stress and it's easier to go to sleep. And just as importantly, my life is more full of all the things I love; I’m not missing out on them. &lt;/p&gt;

&lt;p&gt;What do you think about self care and pacing? What works for you? Feel free to comment below! &lt;/p&gt;

&lt;p&gt;Read &lt;a href="https://dev.to/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-1-3nl0"&gt;Part 1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>productivity</category>
      <category>motivation</category>
    </item>
    <item>
      <title>What I Learned About Attitude and Mindset in Coding Bootcamp Pt. 1</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Wed, 01 Jul 2020 17:31:21 +0000</pubDate>
      <link>https://forem.com/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-1-3nl0</link>
      <guid>https://forem.com/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-1-3nl0</guid>
      <description>&lt;p&gt;Going into the Flatiron bootcamp, I was extremely excited and wanted to just eat up every piece of knowledge and skill I could get my hands on. However, as a newbie, my approach to making it through the bootcamp went through some important changes. It's not just typos and code logic that a new developer has to wrestle with, but also some mental aspects. This article covers the first of three.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Temper your competitive mindset&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are some people who straight up say, “it's not a competition, never compare yourself to others.” However, from my own reflection and seeing how others behave, I think we all have some level of competitive energy, and it can help push us to be our best. It's just a matter of how we harness that energy and our awareness of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake:&lt;/strong&gt; &lt;br&gt;
In the beginning of the bootcamp, I had this mindset of “I need to be the best, I need to outshine everyone in order to be noticed and valid.” This caused me to have expectations that were too high for myself, leading to constant disappointment and led to my second mistake, overworking. What I found out later, was that some of the students had already been coding for years, or had gotten a degree in computer science and had already had developer jobs! Of course, their projects would reflect that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Improvement:&lt;/strong&gt; &lt;br&gt;
According to the Merriam Webster dictionary, to temper something means to “to dilute, qualify, or soften by the addition or influence of something else”. Competitive energy can be a really good thing as long as it's not the only thing driving you. So what can we temper competition with? &lt;/p&gt;

&lt;p&gt;For me, I chose a &lt;strong&gt;progress oriented mindset&lt;/strong&gt;. Essentially, anytime I learned or implemented a new functionality or even a single line of code that worked, no matter how small, I chose to see it as a positive step worthy of celebration. It's turned into a habit now, and I feel much more satisfied and proud of my effort and work this way. &lt;/p&gt;

&lt;p&gt;Another approach I used to temper my competitiveness was focusing on my own &lt;strong&gt;internal goals&lt;/strong&gt; unrelated to what others were doing. I have a dream of making some games and releasing them online on a website I create. Anytime I learn something that contributes to that, I get an endorphin release. &lt;/p&gt;

&lt;p&gt;Now when I reflect on my competitive spirit, I think on how I want my projects to look on par with others and I want people to have a little wow moment when seeing my work, but their reactions don’t weigh on me as heavily since I am driven by multiple facets. &lt;/p&gt;

&lt;p&gt;What approaches do you have regarding your developer work? Where do competition, progress, and goals fit into your mindset? Let me know in the comments : )&lt;/p&gt;

&lt;p&gt;Read &lt;a href="https://dev.to/wolfdominion/what-i-learned-about-attitude-and-mindset-in-coding-bootcamp-pt-2-2keh"&gt;Part 2&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>productivity</category>
      <category>motivation</category>
    </item>
    <item>
      <title>How to 'Not Advertise' Your API Key in React Apps</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Sat, 27 Jun 2020 18:42:32 +0000</pubDate>
      <link>https://forem.com/wolfdominion/how-to-hide-your-api-key-in-react-apps-4dph</link>
      <guid>https://forem.com/wolfdominion/how-to-hide-your-api-key-in-react-apps-4dph</guid>
      <description>&lt;p&gt;Update note: I have revised this article to be more specific about which kind of API I'm talking about after receiving the first several comments. &lt;/p&gt;




&lt;p&gt;In this article, I talk about how to make your frontend API key environment specific. This is for a client-safe key that you would need to use for Google maps or Stripe, for example. I am NOT talking about an AWS key. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why you shouldn't advertise your frontend API key:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;When my instructor told me to never push code to Github that had my API key on it, I wondered how it could possibly matter. His answer was essentially, web crawling software is all over the internet and looks through places like Github, searching for low hanging fruit- in other words a frontend API key that is not environment specific. So how do you make it environment specific? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s how in 4 steps:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;(1) In the root of your directory in your React app, created a file called .env&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XRGBjjtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p766awjoncdzt7isgaa2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XRGBjjtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/p766awjoncdzt7isgaa2.png" alt="file directory in react"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2) Inside of this file, type: &lt;code&gt;REACT_APP_API_KEY=[key]&lt;/code&gt;. Make sure to remove the brackets &lt;code&gt;[ ]&lt;/code&gt;.Example: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QgobWuIW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fch1yn90tba2xdfyxspl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QgobWuIW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fch1yn90tba2xdfyxspl.png" alt=".env file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(3) In your .gitignore file, add &lt;code&gt;.env&lt;/code&gt; on a new line (see line 18)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6fo1t5qK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qkueitevc73jfywnl2s1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6fo1t5qK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qkueitevc73jfywnl2s1.png" alt=".gitignore file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(4) You can then use your key in your app by declaring a variable and set it equal to: &lt;code&gt;process.env.REACT_APP_API_KEY&lt;/code&gt;&lt;br&gt;
Below is an example of how it might declared and used. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HiSHncQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1931w25r0s7qb8rnyhxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HiSHncQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1931w25r0s7qb8rnyhxq.png" alt="example of using key in app.js"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to make a DELETE form using Rails Middleware in 3 easy steps</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Fri, 22 May 2020 19:43:37 +0000</pubDate>
      <link>https://forem.com/wolfdominion/how-to-make-a-delete-form-using-rails-middleware-in-3-easy-steps-1c10</link>
      <guid>https://forem.com/wolfdominion/how-to-make-a-delete-form-using-rails-middleware-in-3-easy-steps-1c10</guid>
      <description>&lt;p&gt;If you’ve recently learned how to create forms for GET and POST methods, your next inclination is probably to try out DELETE or PATCH. However, you’ll quickly find out that forms do not support these and that no one knows exactly why this is (if you happen to know, send me a message!).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wXq2l_4D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbvd9yq090hkou8ltsb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wXq2l_4D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jbvd9yq090hkou8ltsb5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The internet is filled with vague work arounds and half-formed tutorials for making a delete form. It will make you wonder how the heck anyone else figured this out. Turns out, as per usual with programming, there are multiple ways to accomplish this goal. This tutorial will show you one of them so you don’t have to patch together (no pun intended) various ambiguous instructions from multiple websites. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Behold, Rails Middleware...&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What is Middleware, in beginner’s terms?&lt;/strong&gt; &lt;br&gt;
Essentially it is a separation of concerns. Middleware includes a bunch of methods that an HTTP request is passed through before it finally hits your routes and controller methods. Some of this is automatic, and other times, you need to manually enable a certain middleware method. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does this have to do with making a form DELETE rather than GET or POST?&lt;/strong&gt;&lt;br&gt;
Well, if middleware can influence an HTTP request before it hits your controller, then maybe there’s a middleware method that can change your request from GET/POST to DELETE!&lt;/p&gt;

&lt;p&gt;And guess what, there is! It's called &lt;strong&gt;Rack::MethodOverride&lt;/strong&gt;. This magical thing is very obscurely documented, so I’m going to lead you step-by-step on how to get it working. You can also see the code directly on my Github (README tells you how to set it up quickly): &lt;a href="https://github.com/wolf-dominion/sampleAPI_delete_form_tutorial_backend"&gt;Backend repo&lt;/a&gt; | &lt;a href="https://github.com/wolf-dominion/sampleAPI_delete_form_tutorial_frontend"&gt;Frontend repo&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Overview of what to do:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Enable Rack::MethodOverride in your backend&lt;/li&gt;
&lt;li&gt;Create a form in your HTML file&lt;/li&gt;
&lt;li&gt;Customize the form in your Javascript file&lt;/li&gt;
&lt;/ol&gt;




&lt;center&gt;&lt;strong&gt;Step 1: Enable Rack::MethodOverride in your backend&lt;/strong&gt;&lt;/center&gt; 

&lt;ol&gt;
&lt;li&gt;In your Rails application, navigate to ‘config/application.rb’&lt;/li&gt;
&lt;li&gt;Within this file, navigate to the module that has the same label as your application, in my case, SampleApi &lt;/li&gt;
&lt;li&gt;Under “config.load_defaults 6.0”, paste in: “config.middleware.use Rack::MethodOverride” and save. (For the sake of readability, I’ve removed the default comments)
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="nx"&gt;SampleApi&lt;/span&gt;
  &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;Rails&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&gt;Application&lt;/span&gt;

    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;load_defaults&lt;/span&gt; &lt;span class="mf"&gt;6.0&lt;/span&gt;
    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;Rack&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&gt;MethodOverride&lt;/span&gt;

    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api_only&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="nx"&gt;end&lt;/span&gt;
&lt;span class="nx"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;center&gt;&lt;strong&gt;Step 2: Create a form in your HTML file&lt;/strong&gt;&lt;/center&gt;

&lt;ol&gt;
&lt;li&gt;In your HTML file when creating the form, leave the action empty, and set the method to “POST”&lt;/li&gt;
&lt;li&gt;Make an input element inside the form with these attributes:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;type=”hidden”, meaning the user of your webpage will not see it&lt;/li&gt;
&lt;li&gt;name=”_method”, this is for the backend to recognize that this input is actually to be taken as a method&lt;/li&gt;
&lt;li&gt;value=”delete”, this sets the previously mentioned method to DELETE rather than POST
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"_method"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"delete"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;Select book you want to remove from your list:&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;select&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"book-select"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"book_id"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/select&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"Remove book from your list"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;center&gt;&lt;strong&gt;Step 3: Customize the form in your Javascript file&lt;/strong&gt;&lt;/center&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Grab the value in the input field that you want to send to the backend, in the case of DELETE, you’ll want the id of the object you want to delete. In my example, my function is getSelectionValueOnDeleteForm():&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// grabs the initial value when the page loads (in this case, the "Coraline" book)&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;select_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;book-select&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;id_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;select_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;select_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedIndex&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// grabs the value of the menu drop-down selection when the user clicks on a book, &lt;/span&gt;
    &lt;span class="c1"&gt;// but hasn’t pressed submit yet&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;book-select&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;id_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;id_value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Finally, grab the form element and set its action (remember how we left this blank in the HTML file?):&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;setActionTypeOnDeleteForm&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="nx"&gt;id_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getSelectionValueOnDeleteForm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bookDeleteForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;body &amp;gt; form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="nx"&gt;id_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id_value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
     &lt;span class="nx"&gt;bookDeleteForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`http://localhost:3000/books/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id_value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now that these steps are complete, in one terminal from your backend application, run “rails s”. And in another terminal or tab, from your front end folder, run “lite-server”. Watch the magic happen. Or start bug fixing, because if you’re like me, there’s probably a typo or two in there.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Important note&lt;/strong&gt;: If you already had your rails server running and lite-server, you need to restart them in order for the changes to take effect! And don’t forget to look over the README if you’re trying out my example code on Github. If you have any troubles, leave a comment and I'll do my best to help! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;The best articles I can find on Middleware: &lt;a href="https://www.rubypigeon.com/posts/examining-internals-of-rails-request-response-cycle/"&gt;https://www.rubypigeon.com/posts/examining-internals-of-rails-request-response-cycle/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/xngwng/what-is-http-middleware-best-practices-for-building-desiging-and-using-middleware-5g10"&gt;https://dev.to/xngwng/what-is-http-middleware-best-practices-for-building-desiging-and-using-middleware-5g10&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Official guide: &lt;br&gt;
&lt;a href="https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack"&gt;https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>rails</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hello! A small introduction from an artist and software engineer</title>
      <dc:creator>Hannah</dc:creator>
      <pubDate>Thu, 21 May 2020 18:12:26 +0000</pubDate>
      <link>https://forem.com/wolfdominion/hello-a-small-introduction-from-an-artist-and-software-engineer-meh</link>
      <guid>https://forem.com/wolfdominion/hello-a-small-introduction-from-an-artist-and-software-engineer-meh</guid>
      <description>&lt;p&gt;Hello there! This is my first hello to the programming side of the online world.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bodrT0Fp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nmm9iz641xpahni8d6mp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bodrT0Fp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nmm9iz641xpahni8d6mp.png" alt="cartoon self waving"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After getting my B.A. and M.A. in Arts and Technology, I wondered what to do with my life. I’ve always been a creative person and had engineering-like qualities of wanting to solve problems and solve them efficiently, but narrowing down what exactly to become skilled in is hard. &lt;/p&gt;

&lt;p&gt;After a year of freelancing post-college, I became very frustrated one day. I hit a breaking point when designing a Wordpress site for a client, and realized that I was held back by my lack of technical knowledge. I hated that when I used the pre-made themes and templates, I had so much trouble making small tweaks and customized alterations. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D6kBLkUX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/865sfyei1aj7nhnrcefu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D6kBLkUX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/865sfyei1aj7nhnrcefu.png" alt="cartoon self smashing computer in anger"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When looking at the source code, I realized that if only I knew how all this worked, I would have freedom. It was an "ah-ha" moment. If I knew how to code, I would be free. Free to create what I wanted, free to solve the problems that had been eating away at me when I spent hours staring at the screen. &lt;/p&gt;

&lt;p&gt;Over the next few weeks, I had yet another breaking point where I wondered if this meant getting another college degree. I just finished college for crying out loud, I didn’t want to sacrifice yet another 4 or more years just to find a place in life, a career, a meaning. That’s when I came across coding bootcamps, and after hours of discussion with family and friends, and interviewing the bootcamp instructors, I realized that this was exactly what I was looking for. An intense dive into learning skills that would propel me forward, that would build off of what I already know, that would overcome the barrier between my ideas and tangible finished projects. This is what I wanted. &lt;/p&gt;

&lt;p&gt;The next few months involved doing prepwork and trying to learn to code on my own (when I wasn’t freelancing and angrily longing for programming skills). I didn’t just like it, I found it addicting. Getting that adrenaline rush when I overcame a logic problem and made something print out correctly on the screen… I knew this was the right path. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LCsr0Q-y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bzymus6xjztlmbighwqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LCsr0Q-y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bzymus6xjztlmbighwqv.png" alt="cartoon self with a walking stick about to set off on a journey to distance hills"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I’m in the midst of the bootcamp, coding around 10 to 12 hours a day, a complete novice, and only catching glimpses of just how deep the world of programming might be. I’m extremely excited to see where this path in life will take me, and I look forward to sharing my learning process, philosophical thoughts, and projects along the way with you! &lt;/p&gt;

</description>
      <category>self</category>
      <category>introduction</category>
      <category>artist</category>
      <category>bootcamp</category>
    </item>
  </channel>
</rss>
