title: How to write a reusable component for axios.get and axios.post?
body: <p>I am a student focusing on front-end development, mostly React and JavaScript. I got into problem now, I am using axios but in future there will be other library like axios that is more flexible. I am fed up writing an axios call every time in action creators. I want to write a reusable component for my API methods, like I can drag them into my reducer file to use it. when I want to change it I don't have go through all my components to change <code>axios.get</code>.    </p>
  
  <pre><code>import Axios from 'axios'
  
  
   export function GetApiData() {
          return function () {
              Axios.get('/api').then(response=&gt;{
                 console.log(response.data);
              });
          }
      }
  </code></pre>
  
  <p>I have heard that in a production environment companies use a reusable component to work this kind of scenario. I am looking for a reusable component, something like this:</p>
  
  <pre><code>import {get, post} from 'some file'
  
  // code using get or post to make an axios call
  </code></pre>
  
  <p>and use those get instead for Axios.get. I am bad at creating reusable components.</p>