<?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: Augustine Victor</title>
    <description>The latest articles on DEV Community by Augustine Victor (@austinevick).</description>
    <link>https://dev.to/austinevick</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%2F286874%2Fcd433843-b63c-48c7-92b2-53dcd62ad706.png</url>
      <title>DEV Community: Augustine Victor</title>
      <link>https://dev.to/austinevick</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/austinevick"/>
    <language>en</language>
    <item>
      <title>How to create a reusable API service client in react using FETCH.</title>
      <dc:creator>Augustine Victor</dc:creator>
      <pubDate>Mon, 23 Oct 2023 13:36:20 +0000</pubDate>
      <link>https://dev.to/austinevick/how-to-create-a-reusable-api-service-client-in-react-using-fetch-2o8b</link>
      <guid>https://dev.to/austinevick/how-to-create-a-reusable-api-service-client-in-react-using-fetch-2o8b</guid>
      <description>&lt;p&gt;This article will be useful to you if you are like me who doesn't rely much on third party libaries. Let's begin:&lt;/p&gt;

&lt;p&gt;I will be using a mini project for this demo.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyysvsgfyrqbghaex35in.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyysvsgfyrqbghaex35in.PNG" alt="Project structure" width="352" height="404"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;1.&lt;/strong&gt; Create a new react app using vite or CRA but I will be making use of Typescript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; In the service folder we added the API service client.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvr8cfx8qjubtuigkaw6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvr8cfx8qjubtuigkaw6.PNG" alt="API Client" width="550" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; In the hooks folder we make use of the API Client we created earlier.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb1xqu8wzqubeo1kpia6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb1xqu8wzqubeo1kpia6.PNG" alt="Custom hook for API Client" width="655" height="777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; And finally we make use of our custom hook in our components. &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99hhftkttv1vuwzcbidn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99hhftkttv1vuwzcbidn.PNG" alt="Using custom hooks in component" width="700" height="665"&gt;&lt;/a&gt;&lt;br&gt;
This is not a principle but a concept you can apply in your project. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/austinevick/mern-stack-note-app" rel="noopener noreferrer"&gt;Github repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>mern</category>
    </item>
  </channel>
</rss>
