title: how to pass auth token fetched by axios to cy.visit in cypress test
body: <p>I am writing e2e tests using cypress to test our react app. In the spec file, I have following code in the beforeEach,</p>
  <pre><code>describe(&quot;My Test&quot;, () =&gt; {
    beforeEach(() =&gt; {
      cy.visit(
        `/?token=${authToken}&amp;testing=1`
      )
    })
  ...
  }
  </code></pre>
  <p>I need fetch the authToken from another url and the token is expired every hour. I have following code using axios in a separate file:</p>
  <pre><code>import axios from &quot;axios&quot;
  
  export const getAuthToken = () =&gt; {
    const data =...
    const url = `https://.../oauth2/v2.0/token`
    const config = {
      method: 'post' as const,
      url: url,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      data: data
    }
  
    return axios(config).then((response) =&gt; {
      console.log(response.data)
      return (response.data[&quot;access_token&quot;])
    })
  </code></pre>
  <p>But I am not sure how to call getAuthToken in the beforeEach?</p>