<?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: victoriaehrbar</title>
    <description>The latest articles on DEV Community by victoriaehrbar (@victoriaehrbar).</description>
    <link>https://dev.to/victoriaehrbar</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%2F715234%2Ff838bf2d-22ed-463d-9c90-7ce1962fbd24.png</url>
      <title>DEV Community: victoriaehrbar</title>
      <link>https://dev.to/victoriaehrbar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victoriaehrbar"/>
    <language>en</language>
    <item>
      <title>Fetch requests in JavaScript</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Wed, 16 Mar 2022 19:07:34 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/fetch-requests-in-javascript-22c1</link>
      <guid>https://dev.to/victoriaehrbar/fetch-requests-in-javascript-22c1</guid>
      <description>&lt;p&gt;Most of the time in your applications, you will need to access data, or "fetch" it from another source, such as a server, API, etc.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;fetch requests&lt;/strong&gt; come in handy.&lt;/p&gt;

&lt;p&gt;I'll use &lt;a href="https://dog.ceo/api/breeds/image/random"&gt;this free API about dogs&lt;/a&gt; for dummy data.&lt;/p&gt;

&lt;p&gt;A fetch request starts out looking 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;fetch("https://dog.ceo/api/breeds/image/random");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All this does is request the data though; we need some kind of response so we can actually see this data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://dog.ceo/api/breeds/image/random").then((response) =&amp;gt; {

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response object needs to be translated into a JSON so we are able to use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://dog.ceo/api/breeds/image/random").then((response) =&amp;gt; {
  return response.json();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the json() method also returns a promise, let's return that promise and use another then().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://dog.ceo/api/breeds/image/random")
  .then((response) =&amp;gt; {
    return response.json();
  })
  .then((json) =&amp;gt; {
    console.log(json);
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to add a catch() method at the end of the series of then() methods to catch any errors for unsuccessful requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://dog.ceo/api/breeds/image/random")
  .then((response) =&amp;gt; {
    return response.json();
  })
  .then((json) =&amp;gt; {
    console.log(json);
  })
  .catch((err) =&amp;gt; {
    console.log(err);
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>fetch</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React Components</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Wed, 16 Mar 2022 18:43:52 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/react-components-36am</link>
      <guid>https://dev.to/victoriaehrbar/react-components-36am</guid>
      <description>&lt;p&gt;Yesterday I passed my final assessment at Flatiron School on React. I personally found this section to be tough as there was a lot of material to review beforehand. I spent a lot of time mastering the differences between various components, so I thought I would outline it in a blog post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a component and what are the different types of components?&lt;/strong&gt;&lt;br&gt;
The &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;official React documents&lt;/a&gt; on components define it as so:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.&lt;/p&gt;

&lt;p&gt;Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Components contain functions and create presentation of the code. There are two types of components, &lt;strong&gt;container&lt;/strong&gt; and &lt;strong&gt;presentational&lt;/strong&gt; components. There are also two ways to write components, as either &lt;strong&gt;functional&lt;/strong&gt; or &lt;strong&gt;class&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container vs. Presentational&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container&lt;/strong&gt; components deal with function rather than presentation. They tend to be stateful, and will use the redux store to send data to other containers or presentational components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Presentational&lt;/strong&gt; components are used to render views on the frontend. They are stateless and do not have access to redux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional vs. Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functional components&lt;/strong&gt; are written as JavaScript functions an explicitly use return. The return value of the function depends on the props that are passed in. Functional components are used when you are coding presentational components without their own state or access to lifecycle methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class components&lt;/strong&gt; are a JavaScript class that extends React. Class components have lifecycle methods that are used to fetch data and create objects. They are stateful components that control how state changes.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Repost: Flatiron School Phase 1 CLI Project</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Tue, 15 Mar 2022 01:05:21 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/repost-flatiron-school-phase-1-cli-project-4p7d</link>
      <guid>https://dev.to/victoriaehrbar/repost-flatiron-school-phase-1-cli-project-4p7d</guid>
      <description>&lt;p&gt;(This was posted on the Learn.co blogging platform for my Phase 1 Flatiron School project; it is being cross-posted here due to the transition to Canvas and the removal of the Learn.co blogging function).&lt;/p&gt;

&lt;p&gt;I have just completed my CLI Project! I had a little bit of a hard time getting started, mostly due to the decision between scraping and using an API. I had never used an API and felt unfamiliar with them. I had attended a few study group sessions and learned a little bit more about the pros and cons of scraping vs. using an API, and ultimately opted to use an API in my project. It was also a little bit new for me writing code without tests to pass, but it was a great learning experience.&lt;/p&gt;

&lt;p&gt;Once I found a list of public APIs, the idea of building an app around drink recipes became very appealing, so this is what I ultimately chose. With the limited availability of bars and restaurants during 2020 and into 2021, I have been trying to experiment with at-home cocktail recipes. I figured I would actually potentially use this app in my real life outside of Flatiron School, so that became a bonus perk of this project.&lt;/p&gt;

&lt;p&gt;Originally I had planned to only make this project about margarita recipes, but I was pushed by Dustin during study group to expand this to any drink recipe. I therefore was able to modify the code so the API would take any drink recipe input and, if valid, output a recipe with instructions for the user. This was a pretty cool unexpected feature I wasn’t planning on originally having, but made the project more fun and ultimately more useful.&lt;/p&gt;

&lt;p&gt;Once I got the API class working, I moved on to displaying the objects. Once this worked, I also added the feature of asking for a new input if the user put in a drink that the API did not have a recipe for.&lt;/p&gt;

&lt;p&gt;This project definitely taught me a lot about Object Oriented Ruby and I am happy to have synthesized my skills into this project. I was able to connect with peers I hadn’t met before and work with others and learned a lot at the CLI study group sessions. Now that I’ve completed the first project I feel more confident in my abilities to tackle the next ones and am more aware of the resources available to me.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>beginners</category>
    </item>
    <item>
      <title>React Project: Flatiron School Phase 5</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Tue, 08 Mar 2022 01:21:49 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/react-project-flatiron-school-phase-5-d74</link>
      <guid>https://dev.to/victoriaehrbar/react-project-flatiron-school-phase-5-d74</guid>
      <description>&lt;p&gt;I have just finished my final project at Flatiron School. This 5th and final module focuses on React and Redux. &lt;/p&gt;

&lt;p&gt;This project rates and reviews different BBQ restaurants. As a new Texan, I am attempting to try as many BBQ restaurants as possible from &lt;a href="https://www.texasmonthly.com/interactive/top-50-bbq-2021/"&gt;The Top 50 Texas BBQ Joints: 2021 Edition from Texas Monthly&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Similarly to the Phase 4 JavaScript project, this project was created with 2 repos (&lt;a href="https://github.com/victoriaehrbar/bbq-frontend"&gt;frontend&lt;/a&gt;; &lt;a href="https://github.com/victoriaehrbar/bbq-backend"&gt;backend&lt;/a&gt;). The backend is a Ruby on Rails API and the frontend was created with the create-react-app command. I decided to keep this project very simple in an MVP format, as I will have the option to enhance this project, as well as my 4 other projects, after graduation as a way of keeping my coding skills up to date.&lt;/p&gt;

&lt;p&gt;The backend was fairly simple to set up. I used the Rails scaffold generator to create the BBQ model and some seed data.&lt;/p&gt;

&lt;p&gt;Then I moved on to the frontend. The create-react-app command adds boilerplate code to get started. I then used npm to add Redux, Thunk, and React Router. As stated before, I decided to leave this in an MVP format so I can enhance this project after I graduate, so I did not add bootstrap or any styling.&lt;/p&gt;

&lt;p&gt;Then I had to set up the App component, the Index component, the redux store, and my reducer.&lt;/p&gt;

&lt;p&gt;I then set up my BBQ components (index, form, listitem). ListItem displays the restaurants nicely on the index, and the form allows the user to add a new BBQ restaurant review.&lt;/p&gt;

&lt;p&gt;The addition of a navbar allows the user to go to the home page, add a BBQ restaurant, or view all of them. &lt;/p&gt;

&lt;p&gt;Overall, this was a tough project and I learned a lot about React and Redux. I look forward to building more features on this project in the future.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JavaScript Project</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Fri, 14 Jan 2022 17:34:42 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/javascript-project-4j99</link>
      <guid>https://dev.to/victoriaehrbar/javascript-project-4j99</guid>
      <description>&lt;p&gt;I finished my phase 4 project for Flatiron School! I created a single-page web application for my JavaScript project.&lt;/p&gt;

&lt;p&gt;I created 2 separate repos for the &lt;a href="https://github.com/victoriaehrbar/book_review_frontend"&gt;front end&lt;/a&gt; and &lt;a href="https://github.com/victoriaehrbar/book_review_backend"&gt;back end&lt;/a&gt;. The back end was fairly similar to the phase 3 Rails project, with controllers, models, and has_many relationships. &lt;/p&gt;

&lt;p&gt;My project was a book review/tracker, where a user can input a title, author, description, and category/genre. A category has_many books and a book belongs_to a category.&lt;/p&gt;

&lt;p&gt;While it was interesting to create a mini Rails project and review some old material, I was most interested in the front end JavaScript portion and refining what I learned in phase 4. I utilized the fetch method to get the book data to display on the page, display new posts, and to delete posts. &lt;/p&gt;

&lt;p&gt;The back end part of the project required creating a Rails API, which was interesting as the phase 3 Rails project did not incorporate this. The front end JavaScript portion of this project communicates with the API for the front end and back end to work together.&lt;/p&gt;

&lt;p&gt;In JavaScript, event listeners are used to create actions. For example, my project has an attachDeleteButtonListener, which lets the server know that when the delete button is clicked, that book entry should be removed from the page. There is also another event listener that lets the page know to create a new book when "submit" is clicked on the new book form.&lt;/p&gt;

&lt;p&gt;Overall, the JavaScript project was a great fusion of Rails and JavaScript that allowed me to synthesize my JavaScript knowledge and create a fun single-page web application.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Rails Blog Post</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Tue, 30 Nov 2021 19:42:42 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/rails-blog-post-c66</link>
      <guid>https://dev.to/victoriaehrbar/rails-blog-post-c66</guid>
      <description>&lt;p&gt;I finished my Rails blog post for my Phase 3 project at Flatiron School.&lt;/p&gt;

&lt;p&gt;I decided to create a project similar to my Sinatra project; my Sinatra project was a "pupdate" blog to keep up with puppy updates and my Rails project is about rating dog training. Dogs are given a score, top scores are displayed separately, and the scores have space for descriptions on training progress.&lt;/p&gt;

&lt;p&gt;I created models and controllers for the training updates, the dogs, and the users. A breed model also allowed for a dog to belong_to a breed. I set up the has_many and belongs_to relationships as needed.&lt;/p&gt;

&lt;p&gt;Users are able to log in, log out, see the dogs listed that are available to provide a training score for, or create a new dog to score. Validations are in place so users are not able to update others' scores or added dogs.&lt;/p&gt;

&lt;p&gt;Another element of this project that is more advanced than Sinatra is that there is the option to log in with Google. Omniauth allows users to log in with third-party logins, such as Facebook, Twitter, Github, or Google. I chose to do Google. Users can use their Google account to log in.&lt;/p&gt;

&lt;p&gt;If you want to check out my project, here is the &lt;a href="https://github.com/victoriaehrbar/dog-blog"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rails</category>
    </item>
    <item>
      <title>Sinatra Assessment</title>
      <dc:creator>victoriaehrbar</dc:creator>
      <pubDate>Tue, 28 Sep 2021 23:43:09 +0000</pubDate>
      <link>https://dev.to/victoriaehrbar/sinatra-assessment-6b4</link>
      <guid>https://dev.to/victoriaehrbar/sinatra-assessment-6b4</guid>
      <description>&lt;p&gt;I just got a new puppy, so I was inspired to create the Pupdate Blog to create posts about my puppy's training progress. However, anyone can sign up, log in, and create their own Pupdates about their own dog.&lt;/p&gt;

&lt;p&gt;First, I used the corneal-new gem to create boilerplate code. I added views, models, and controllers. &lt;/p&gt;

&lt;p&gt;Users sign up using an email and password. I used the bcrypt gem to ensure the user's password is protected. &lt;/p&gt;

&lt;p&gt;Then I set up the UsersController and PupdatesController files and mounted them in config.ru. I also added "user Rack::MethodOverride" to give access to Rack middleware so my app will have access to HTTP verbs other than GET and POST, such as PATCH and DELETE.&lt;/p&gt;

&lt;p&gt;I created two migrations with rake db:create_migration: one for the users table and one for the pupdates table. The users table has 3 columns: name, email, password_digest. The pupdates table has a title, content, and a user_id. &lt;/p&gt;

&lt;p&gt;Next, I created a seed file to fill the table with some dummy data to play with and test the app's functionality.&lt;/p&gt;

&lt;p&gt;Back in the controllers, I created the routes needed for the UsersController to sign up, log in, and log out. I also added in the PupdatesController the ability to create a new post, edit a post, and delete a post. I also authenticated the user to ensure that a user can't edit or delete other users' posts. Helper methods were useful for that!&lt;/p&gt;

&lt;p&gt;Since all of the functions are behaving well, I added some UX features. I used the flash gem to flash messages at users to give them information. For example, when you delete a post, "Pupdate deleted" appears on the screen. Users also see a flash message when they enter invalid login credentials.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
