<?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: Udeh Princewill Nzubechukwu</title>
    <description>The latest articles on Forem by Udeh Princewill Nzubechukwu (@zubeco).</description>
    <link>https://forem.com/zubeco</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%2F888788%2Faa092bbf-5141-4398-a61d-9f0da7caa2e8.png</url>
      <title>Forem: Udeh Princewill Nzubechukwu</title>
      <link>https://forem.com/zubeco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/zubeco"/>
    <language>en</language>
    <item>
      <title>How to fetch data using Axios in React</title>
      <dc:creator>Udeh Princewill Nzubechukwu</dc:creator>
      <pubDate>Sun, 01 Jan 2023 11:35:46 +0000</pubDate>
      <link>https://forem.com/zubeco/how-to-fetch-data-using-axios-in-react-3obm</link>
      <guid>https://forem.com/zubeco/how-to-fetch-data-using-axios-in-react-3obm</guid>
      <description>&lt;p&gt;I'm sure almost all Frontend developers at some point might encountered have a need to fetch some data from an API to display on the UI, and today i will be teaching you how to do that in a React Application and we will be using a popular Javascript library called Axios. &lt;/p&gt;

&lt;p&gt;Axios is a popular library for making HTTP requests in JavaScript. It's often used with React to fetch data from an API and populate a website with the fetched data. Here's a brief tutorial on how to use Axios to fetch data in a React app&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, you'll need to install Axios in your React project. You can do this by running the following command in your terminal:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using npm:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Using yarn:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Next, you'll need to import Axios into your React component. You can do this by adding the following line to the top of your file:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now you can use Axios to make HTTP requests from your React component. Here's an example of how to fetch data from an API using Axios:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;axios.get('https://my-api.com/endpoint')
  .then(response =&amp;gt; {
    // handle success
    console.log(response.data);
  })
  .catch(error =&amp;gt; {
    // handle error
    console.log(error);
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the example above, we're using the &lt;em&gt;&lt;strong&gt;GET&lt;/strong&gt;&lt;/em&gt; method to send a GET request to the specified endpoint. You can also use Axios to send POST, PUT, and DELETE requests. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you've received the data from the API, you can use it to update the state of your React component. Here's an example of how to do this:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data: []
    };
  }

  componentDidMount() {
    axios.get('https://my-api.com/endpoint')
      .then(response =&amp;gt; {
        this.setState({ data: response.data });
      })
      .catch(error =&amp;gt; {
        console.log(error);
      });
  }

  render() {
    return (
      &amp;lt;div&amp;gt;
        {this.state.data.map(item =&amp;gt; (
          &amp;lt;div key={item.id}&amp;gt;{item.name}&amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the example above, we're using the componentDidMount lifecycle method to make the API request when the component is mounted. The data that we receive from the API is then stored in the component's state, which we can access using this.state.data. Finally, we use the map function to iterate over the data and render a list of items.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this helps! Let me know if you have any questions.&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>3 HTML5 tags you didn't know existed.</title>
      <dc:creator>Udeh Princewill Nzubechukwu</dc:creator>
      <pubDate>Fri, 08 Jul 2022 00:52:29 +0000</pubDate>
      <link>https://forem.com/zubeco/3-html5-tags-you-didnt-know-existed-30gf</link>
      <guid>https://forem.com/zubeco/3-html5-tags-you-didnt-know-existed-30gf</guid>
      <description>&lt;p&gt;There are well over 100 HTML tags. We all know the basics such as div, p, img. But here are three dynamic tags you probably didn't know about.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Progress Tag
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The "progress" tag is an easy way to display a progress bar using only HTML. Of course, you can also update the value with JavaScript and move it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;progress&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"100"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;30%&lt;span class="nt"&gt;&amp;lt;/progress&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Details Tag + Summary Tag = Accordion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you use the "Details" and "Summary" tags together, you'll get a very simple accordion right out of the box, without the need for JS at all.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;details&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;Now open the accordion&lt;span class="nt"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
      And here is the accordion body
    &lt;span class="nt"&gt;&amp;lt;/details&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Abbreviation (abbr)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can use the "abbr" tag to add notes to the abbreviation. Very useful when writing technical content with many shortcuts that we usually take for granted.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;abbr&lt;/span&gt; &lt;span class="na"&gt;title=&lt;/span&gt;&lt;span class="s"&gt;"World Health Organization"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;WHO&lt;span class="nt"&gt;&amp;lt;/abbr&amp;gt;&lt;/span&gt; was founded in 1948.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Thanks for following along and would love to have a feedback of how this helped you.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>progresstag</category>
      <category>abbrtag</category>
      <category>detailstag</category>
      <category>html</category>
    </item>
  </channel>
</rss>
