Resolve axios to a variable instead of doing everything in the callback : <p>So I am 99% sure this cannot be done, but humor me for a moment. Consider the two functions:</p>

<pre><code>function doAjaxCall(fieldTocheckAgainst, currentField, value) {
  axios.get(
    window.location.origin +
    '/api/clinic/'+window.id+'/patient/'+window.secondId+'/field-validation',
    {
      params: {
        field_to_check_against: fieldTocheckAgainst,
        current_field: currentField,
        value: moment(value).format('YYYY-MM-DD')
      }
    }
  ).then((result) =&gt; {
    return result.data
  });
}

async function resolveAjaxCall(fieldTocheckAgainst, currentField, value) {
  const result = await doAjaxCall(fieldTocheckAgainst, currentField, value)

  console.log(result);
}
</code></pre>

<p>I am attempting to resolve the axios ajax call into a variable based on what I saw <a href="https://stackoverflow.com/a/43371957/1270259">here</a> and it doesn't work. I get <code>undefined</code>.</p>

<p>I understand when it comes to callbacks, everything has to be done in the callback, but is there no way, with async and await to resolve the promise to a variable as I am attempting to do, to then use said variable else where?</p>

<p><strong>Or am I just going to be stuck with callbacks?</strong> </p>
