title: How to send POST response to another function using React.js and axios?
body: <p>I have <code>fileUploadHandler</code> function as below that POST the file.
  The response of post would look like: <code>{ filename: '123sdfg.xlsx' }</code></p>
  <pre><code>fileUploadHandler = (fileData) =&gt; {
      const formData1 = new FormData();
      formData1.append(&quot;file&quot;, fileData)
      postFileUpload(formData1).then((result) =&gt; console.log(&quot;response&quot;, result.data));    
    };
  </code></pre>
  <p>I tried below code, but throws error that storeFile undefined.</p>
  <pre><code>fileUploadHandler = (fileData) =&gt; {
      const formData1 = new FormData();
      formData1.append(&quot;file&quot;, fileData)
      postFileUpload(formData1).then((result) =&gt; storeFile(result.data)); 
      storeFile;
    };
  </code></pre>
  <p>post call function looks as below:</p>
  <pre><code>export const postFileUpload = (values) =&gt; {
    return new Promise((resolve, reject) =&gt; {
      axios    
      .post('&lt;URL&gt;', values)
      .then((result) =&gt; {
        if (result) {
          resolve(result);
        }
      })
      .catch((error) =&gt; {
        reject({ message: &quot;Error:&quot; + error.message });
      });
    });
  }
  </code></pre>
  <p>I want handler not only to post file, but get response, and send the response to a another function.
  How to return the response from fileUploadHandler to another function like formSubmit (an example).</p>