title: Proxy API request through Express return pending Promise instead of response
body: <p>I am currently trying to work with the Atlassian Jira rest API. In order to not get a CORS error I go through the recommended route of not sending the request from the browser but proxy it through my express server. </p>
  
  <p>Now as I am doing this, all I receive back in the app is a pending promise. I assume that I have not correctly resolved it at one point but I cant figure out where. </p>
  
  <p><em>API Handler sending the request to the proxy:</em> </p>
  
  <pre><code>const baseURL = `${apiConfig}/jiraproxy`;
  
  export const testConnection = integration =&gt; {
    return fetch(`${baseURL}/get`, {
      method: "POST",
      headers: { "content-type": "application/json" },
      body: JSON.stringify(integration)
    })
      .then(handleResponse)
      .catch(handleError);
  };
  </code></pre>
  
  <p>Jira Proxy Endpoint on the Express Server</p>
  
  <pre><code>const baseURL = `rest/api/3/dashboard`;
  
  router.post("/get", (req, res) =&gt; {
    fetch(req.body.link + baseURL, {
      method: "GET",
      headers: { Accept: "application/json" },
      auth: {
        username: req.body.credentials.username,
        password: req.body.credentials.token
      }
    })
      .then(handleResponse)
      .catch(handleError);
  });
  </code></pre>
  
  <p>handleResponse &amp; handle Error Methods: </p>
  
  <pre><code>async function handleResponse(response) {
    if (response.ok) {
      return response.json();
    }
    if (response.status === 400) {
      const error = await response.text();
      throw new Error(error);
    }
    throw new Error("Network response was not ok.");
  }
  
  function handleError(error) {
    // eslint-disable-next-line no-console
    console.error(`API call failed. ${error}`);
    throw error;
  }
  </code></pre>
  
  <p><strong>Goal:</strong>
  Send the request of sending a request to the proxy and return the resonse of the proxy as the return of the initial "testConction" method. </p>
  
  <p><strong>Error:</strong>
  No errors thrown, but the response received in the Browser is a pending promise.</p>