<?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: Daniel Trejo</title>
    <description>The latest articles on DEV Community by Daniel Trejo (@daniel_trejo14).</description>
    <link>https://dev.to/daniel_trejo14</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%2F1549104%2F8ecffb66-de63-492f-93a1-47cac96bcd20.jpg</url>
      <title>DEV Community: Daniel Trejo</title>
      <link>https://dev.to/daniel_trejo14</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daniel_trejo14"/>
    <language>en</language>
    <item>
      <title>Project 5 Capstone</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Thu, 03 Oct 2024 17:32:10 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/project-5-capstone-ihl</link>
      <guid>https://dev.to/daniel_trejo14/project-5-capstone-ihl</guid>
      <description>&lt;p&gt;I just completed my Phase 5 and it threw me for a loop. It was one of the hardest challenges I have ever done. I have never seen so many issues to debug and reasons I wanted to just quit but with every inch I climbed, I would learn something new and get that much closer to finally getting it done. The easy part was starting the project. Creating all the initial routes and models took no time at all. &lt;/p&gt;

&lt;p&gt;The hardest part was re-familiarizing myself with React and all that front end stuff. That is what made this project take so long. Trying to remember how to code all the handleSubmits, handleDelete, etc... took so freaking long. There are tons of people out there that might look at this blog and say "Oh, all that stuff is easy", but I'm still learning and I plan to keep on learning. This program is so insanely good because not only do you get amazing teachers and staff but you also make a lot of friends. Having these online cohorts really made it easier to reach out and talk to other. &lt;/p&gt;

&lt;p&gt;I definitely will never stop learning code. It is so cool and fulfilling to get a project working just right. It's worth all the struggle to me. For some reason specifically one of the biggest issues I ran into was my CRUD, usually that wasn't much of a problem but once I created one, the other stopped working which was super annoying for a few hours. Finally I was able to get them both to work but not fully. I am able to update fully and the delete worked on the first try, but any following attempts to delete would just throw me an error that I couldn't figure out.&lt;/p&gt;

&lt;p&gt;If you are thinking about doing coding at all regardless of the field you go into. I fully recommend it because it is one of the most fulfilling things you can do. There is a lot of long nights and a lot of coffee, but I still think it's fun. One thing I learned is the importance of teammates. Working with a group on one project relieved so much stress because you weren't the sole person responsible for the entire project. Being able to bounce ideas of off people and ask for help is something you will be doing for the rest of your life and I'm totally ok with that. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Beginner's guide to APIs: Understanding POST, PATCH, GET, and DELETE</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Fri, 13 Sep 2024 12:47:06 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/a-beginners-guide-to-apis-understanding-post-patch-get-and-delete-55el</link>
      <guid>https://dev.to/daniel_trejo14/a-beginners-guide-to-apis-understanding-post-patch-get-and-delete-55el</guid>
      <description>&lt;p&gt;It took me a good while to figure out what I was going to write about but i decided to go with APIs. Today we are going to dive into a subject that at first might seem a little scary but it's actually super easy and essential for building web applications. I'm just going to cover the four fundamental actions you can perform with APIs: POST, PATCH, GET, and DELETE.&lt;/p&gt;

&lt;p&gt;Before we jump into the different type of actions, let's cover what an API is. API stands for Application Programming Interface. It allows programs to talk to each other. When coding, you often need your program to interact with other programs or services. APIs is how your going to get that done. &lt;/p&gt;

&lt;p&gt;Think of an API like a waiter at a restaurant. You (the user) tell the waiter (API) what you want from the menu (the service), and then the waiter brings back the food (response).&lt;/p&gt;

&lt;p&gt;Let’s start with GET.&lt;/p&gt;

&lt;p&gt;What It Does: GET is used when you want to retrieve or fetch data from a server. It’s like asking the waiter to bring you a menu or to show you a dish that you’re interested in.&lt;br&gt;
Example: Imagine you’re working on a website that shows user profiles. If you want to display a user’s profile information, you’d use a GET request to fetch that data from the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route('/users/&amp;lt;int:user_id&amp;gt;', methods=['GET'])
def get_user(user_id):
    user = users.get(user_id)
    if user:
        return jsonify(user)
    else:
        return jsonify({'error': 'User not found'}), 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next up is POST.&lt;/p&gt;

&lt;p&gt;What It Does: POST is used when you want to send new data to the server. It’s like telling the waiter you want to order a new dish.&lt;br&gt;
Example: Let’s say you’re building a sign-up form for a website. When a user fills out the form and hits submit, a POST request is sent to the server to create a new user account with the provided details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route('/users', methods=['POST'])
def create_user():
    new_user = request.json
    user_id = max(users.keys()) + 1 if users else 1
    users[user_id] = new_user
    return jsonify({'id': user_id, **new_user}), 201
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s talk about PATCH.&lt;/p&gt;

&lt;p&gt;What It Does: PATCH is used to update or modify existing data on the server. It’s like asking the waiter to change an ingredient in your dish.&lt;br&gt;
Example: Suppose you want to update the email address of an existing user. You’d use a PATCH request to send only the updated information to the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route('/users/&amp;lt;int:user_id&amp;gt;', methods=['PATCH'])
def update_user(user_id):
    user = users.get(user_id)
    if not user:
        return jsonify({'error': 'User not found'}), 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we have DELETE.&lt;/p&gt;

&lt;p&gt;What It Does: DELETE is used to remove data from the server. It’s like telling the waiter you don’t want a dish anymore and asking them to take it off your table.&lt;br&gt;
Example: If you want to delete a user’s profile, you’d use a DELETE request to remove that user’s data from the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.route('/users/&amp;lt;int:user_id&amp;gt;', methods=['DELETE'])
def delete_user(user_id):
    if user_id in users:
        del users[user_id]
        return jsonify({'message': 'User deleted'})
    else:
        return jsonify({'error': 'User not found'}), 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>One-to-many &amp; Many-to-many</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Thu, 01 Aug 2024 03:25:06 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/one-to-many-many-to-many-3agk</link>
      <guid>https://dev.to/daniel_trejo14/one-to-many-many-to-many-3agk</guid>
      <description>&lt;p&gt;Hello, my name is Daniel and I'm a student at flatiron. I am currently working through my project in phase-4 which is really challenging but I am learning a lot from all of it. One thing that screwed me over before and took me some time to understand was one-to-many and many-to-many. It took me way too long to understand what that meant and how it was supposed to work in my project. I understood a one-to-many a lot faster than I did a many-to-many because in my last project. I created and library management system and it allowed people to create authors and books using python. &lt;/p&gt;

&lt;p&gt;Author was one and that books were the many. Each author had an infinite number of books they could have while a book could realistically only have one author. One(author)-to-many(books).&lt;/p&gt;

&lt;p&gt;Now for many-to-many, we had to use both in phase 4 project and I went with a blog page ironically. Post was a one-to-many and so was the user but the comments was a many-to-many because it had both the posts and the user connected to it. It showed which post it was commented on using the posts id and then also showed who wrote the comment by showing the user's id when they comment. So that's a many-to-many and that took too long for me to understand.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Phase 3 sql, tuples, and object problems</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Thu, 11 Jul 2024 20:29:48 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/phase-3-sql-tuples-and-object-problems-1k8d</link>
      <guid>https://dev.to/daniel_trejo14/phase-3-sql-tuples-and-object-problems-1k8d</guid>
      <description>&lt;p&gt;Hello, my name is Daniel Trejo and I'm a student at Flatiron School in the Software Engineering program. Phase 3 was definitely the hardest one yet because of the sheer amount of curriculum. The hardest part for me was the project which is probably not surprising due to the fact that it is the final project of the phase. However I ran into a ton of issues right off the bat but once I got started it wasn't actually that bad. That was until I finished it. Now you might be saying, "It's being done a good thing?" Normally yes but with coding, finishing coding doesn't always mean the project is done.&lt;/p&gt;

&lt;p&gt;Now I ran into a heap of issues at this point and they were are super simple fixes except for one. I needed get some data to display at the end of another piece of data but these 2 pieces of data are from different places. Now to some people that might be a simple fix but to me who has been struggling a lot recently with personal stuff and just the scope of the phase. It took me until doing the project to even start completely understanding python, cli, orm, and sql as is. &lt;/p&gt;

&lt;p&gt;The problem was I wasn't grabbing the information correctly so I had to create a whole new function and test run for hours trying to get the right thing. Once I finally did, I was so happy but that was until I ran into another problem.&lt;/p&gt;

&lt;p&gt;I needed it to return an object but all it kept returning was a tuple. Which meant the information I was getting wasn't returning at all. That's when I found out through using one of the best tools in python,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;breakpoint()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;that it WAS returning something and it was a tuple but my program didn't know what to do with that tuple. It wasn't actually showing anything on the return until I grabbed the index of that information with &lt;code&gt;[0]&lt;/code&gt; brackets. Yay finally it was fixed, however, what everyone will deal with after fixing something. Another problem popped up. It was that I was returning everything as a tuple which meant as a string. A requirement of the project was to be able to view related object. I was viewing just the string of what I needed which isn't an object. So that's when I figured out that I needed to return an object not a tuple. Instead of using sql 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;sql = """
    SELECT name
    FROM authors
    WHERE id = ?
""" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I had to use it 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;sql = """
    SELECT *
    FROM authors
    WHERE id = ?
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first way was just grabbing the string(name) instead of grabbing the whole object, which the second version did. Then I had to call it in my repr as self.author().name because doing .name is one of the 2 ways to grab something from an object. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring Destructuring in JS</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Wed, 12 Jun 2024 21:15:32 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/exploring-destructuring-in-js-114j</link>
      <guid>https://dev.to/daniel_trejo14/exploring-destructuring-in-js-114j</guid>
      <description>&lt;p&gt;Hello, my name is Daniel and I'm a beginner at coding. I am an active student at Flatiron School. In phase-2 we delve heavily into react and all the amazing things it can do. Today I decided to talk about Destructuring a little because it is a super simple yet amazing piece of code. Destructuring allows for a more concise and cleaner code. If I were to have code 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;function EmojiButton(props) {
  return (
    &amp;lt;button&amp;gt;
      &amp;lt;span role="img"&amp;gt;{props.emoji}&amp;lt;/span&amp;gt;
      {props.label}
    &amp;lt;/button&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you take a look at the code block, you will see that in some brackets there are some react components that lets us access that information we are grabbing from the &lt;code&gt;props.emoji&lt;/code&gt; and the &lt;code&gt;props.label&lt;/code&gt;. Destructuring can be used to clean up some of the the unnecessary words. We can do this a couple ways. One way to do it is doing a const and assigning them as variable that equal the word "props". That will allow us to go without the word props within the components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function EmojiButton(props) {
const { emoji, label } = props
  return (
    &amp;lt;button&amp;gt;
      &amp;lt;span role="img"&amp;gt;{emoji}&amp;lt;/span&amp;gt;
      {label}
    &amp;lt;/button&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, it looks a little nicer not having the props all over the place. Now I know it doesn't look like it's doing to much here but I promise when you start coding bigger and longer projects. It will start looking all over the place. Props will be literally everywhere. This way you can see exactly what is it's talking about in a specific piece of code instead of looking through "props" over and over again. &lt;/p&gt;

&lt;p&gt;Now, I prefer a different way of desctructuring and it looks 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;function EmojiButton({emoji, label}) {
  return (
    &amp;lt;button&amp;gt;
      &amp;lt;span role="img"&amp;gt;{emoji}&amp;lt;/span&amp;gt;
      {label}
    &amp;lt;/button&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does the same thing as the code block before however I really like the fact that it is integrated into the function itself instead of creating a const variable. It looks a lot nicer and cleaner. Now there will be use cases for both and obviously go with whichever one you feel more comfortable with. A lot of coding is preferences with how you want to go about it. Anyway, destructuring is super useful later one when you coding more than a few lines. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring addEventListeners</title>
      <dc:creator>Daniel Trejo</dc:creator>
      <pubDate>Thu, 30 May 2024 17:24:39 +0000</pubDate>
      <link>https://dev.to/daniel_trejo14/exploring-addeventlisteners-28lj</link>
      <guid>https://dev.to/daniel_trejo14/exploring-addeventlisteners-28lj</guid>
      <description>&lt;p&gt;Hey, my name is Daniel and I'm a beginner at all this coding stuff. I'm currently enrolled in Flatiron School for Software Engineer. The first phase was predominantly on JavaScript and it already caught my interest. There are so many things you can do with JavaScript. There's iterations, variables, scope, and the one I'm going to be talking about, Events. Events where there first subject I really thought I grasp almost fully and that was a good feeling on it's own. &lt;/p&gt;

&lt;p&gt;At first it was a lot to try and take in at once but after a couple times implementing it into my code for project, labs, and challenges. It really helped get it into prospective for me. It peaked my interest the most because the code itself made sense on it's own. For example, if I were to have something in html with the id of Search, if I wanna select that specific id and add a eventlistener to it, I would use either,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.querySelector("#search")&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;code&gt;document.getElementById("search")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Both roughly do the same things, however that have a slight difference as well. querySelector selects the first element in the DOM that matches the specified CSS selector. It is more versatile then getElementById however it is lest straightforward a little slower. Using getElementById is more straightforward and it's generally faster when specifically selecting id's. To add an event to the &lt;code&gt;id="search"&lt;/code&gt; You would follow &lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.getElementById&lt;/code&gt;&lt;br&gt;
with &lt;br&gt;
&lt;code&gt;document.getElementById("search").addEventListener("click", function() {&lt;br&gt;
        alert("I've been cliked!");&lt;br&gt;
    });&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The addEventListener piece is giving the search id an event and in our case it's a click event. Now when we click on whatever we have as our search, either a 🔍 or a search button. It will send an alert to the user with whatever you put for the alert to say. &lt;/p&gt;

&lt;p&gt;There are tons of different events that you can use like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;mouseover&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;click&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;key(any direction)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and so many more that it would take awhile to list them all out here but the fact that there are so many intrigues me. It means that I will constantly be learning and that actually excites me. I would love to pursue as many of those events that I can and not just those but all of coding. I tried so many times to find something that actually interests me and finally I have a profession that actually excites me to learn about. &lt;/p&gt;

&lt;p&gt;//Information on eventlisteners&lt;br&gt;
&lt;a href="https://www.w3schools.com/js/js_htmldom_eventlistener.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_htmldom_eventlistener.asp&lt;/a&gt;&lt;/p&gt;

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