title: How to convert cURL to Axios request
body: <p>I am trying to convert a cURL request from <a href="https://anypoint.mulesoft.com/exchange/portals/nz-post-group/b8271f09-2ad8-4e1c-b6b1-322c5727d148/shippingoptions-api/api/2.0.0/pages/Authentication/" rel="nofollow noreferrer">here</a> to Axios.</p>
  <pre class="lang-bash prettyprint-override"><code>curl -d &quot;grant_type=client_credentials\
  &amp;client_id={YOUR APPLICATION'S CLIENT_ID}\
  &amp;client_secret={YOUR APPLICATION'S CLIENT_SECRET}&quot;\
  https://oauth.nzpost.co.nz/as/token.oauth2
  </code></pre>
  <p>This works fine (when I put my credentials in).</p>
  <p>I tried the following code:</p>
  <pre><code>import axios from &quot;axios&quot;;
  
  async function testApi() {
    try {
      const b = await axios.post(&quot;https://oauth.nzpost.co.nz/as/token.oauth2&quot;, {
        client_id: &quot;xxxxxxxxxxxxxxxxxxxxxxxxx&quot;,
        client_secret: &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;,
        grant_type: &quot;client_credentials&quot;
      });
    } catch (error) {
      console.log(error);
    }
  }
  
  testApi();
  </code></pre>
  <p>This fails with <code>Error 400. grant_type is required</code>. I have tried putting it as a parameter, enclosing within a <code>data: json</code> block. I can't figure this out.</p>