title: How can I cast a string to number in an response using axios?
body: <p>I am using Axios to execute a GET request to a public API. This API return a numeric value as string. I need to cast this value a numeric value. My application runs using tsc, so I expect the result of my object to be a numeric value, but it's not.</p>
  <p><strong>Axios Response</strong></p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;name&quot;: &quot;foo1&quot;,
      &quot;value&quot;: &quot;8123.3000&quot;
    },
    {
      &quot;name&quot;: &quot;foo2&quot;,
      &quot;value&quot;: &quot;5132.2003&quot;
    },
    {
      &quot;name&quot;: &quot;foo3&quot;,
      &quot;value&quot;: &quot;622.0000&quot;
    }
  ]
  </code></pre>
  <p><strong>Expected Output</strong></p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;name&quot;: &quot;foo1&quot;,
      &quot;value&quot;: 8123.3
    },
    {
      &quot;name&quot;: &quot;foo2&quot;,
      &quot;value&quot;: 5132.2003
    },
    {
      &quot;name&quot;: &quot;foo3&quot;,
      &quot;value&quot;: 622
    }
  ]
  </code></pre>
  <p>My code is very simple,</p>
  <pre class="lang-js prettyprint-override"><code>interface MyObj {
    myString: string;
    myNumber: number;
  }
  
  (async () =&gt; {
    let { data }: AxiosResponse&lt;MyObj&gt; = await axios.get&lt;MyObj&gt;(&quot;/public/data&quot;);
    console.log(data);
  })();
  </code></pre>
  <p>I try to use <code>interface</code>, <code>class</code>, the interface <code>Number</code>. Nothing worked.</p>
  <p><a href="https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgLIE8DyAjAVsgbwFgAoZc5AW3QGUwpQBzALmQGd6mBuUiq9AHIBXStmisQIsVB4kAvqVIAbCGGRQIbAA4B7EGwh0GIRsgC8yAAakA2r0L3yAIhBxKEJ6ycwdOgIxOADSOyE4AbnBKQh5eABx+AEwAzAB0SQAMmU72csFkDvnOru6eoT46CUEh4ZHRpU4ArH5JCSkJmUnZ+bn2xIWhxTFlvp15fDVRQ04AbAmtmVk5pAC61iTKqsg6eKwYOLg2y+bIAFI0mAIpWnBQBgAUGtp6BkZMAJSypAjPOiopSjpGHdtrg3qQgA" rel="nofollow noreferrer">I leave an example of code to try it.</a></p>
  <p>How can I get the expected output without manually converting each value one by one?</p>