async function getResponseBody()

in packages/gitlab-api-client/src/createResponseError.ts [3:17]


async function getResponseBody(response: Response): Promise<unknown> {
  try {
    if (response.headers.get('Content-Type') === 'application/json') {
      return await response.json();
    }

    // note: Let's just return a text representation of the response as a sensible default
    return await response.text();
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(`Failed to parse response body of ${response.url}`, e);

    return '';
  }
}