Language: TypeScript
Label: vulnerable
CWE: CWE-200 \u2014 Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.

Code:
export async function requestTranslationsAPI<T>(
  translationsUrl: string = '',
  locale = '',
  init: RequestInit = {},
  serverSettings: ServerConnection.ISettings | undefined = undefined
): Promise<T> {
  // Make request to Jupyter API
  const settings = serverSettings ?? ServerConnection.makeSettings();
  translationsUrl =
    translationsUrl || `${settings.appUrl}/${TRANSLATIONS_SETTINGS_URL}`;
  const requestUrl = URLExt.join(settings.baseUrl, translationsUrl, locale);
  let response: Response;
  try {
    response = await ServerConnection.makeRequest(requestUrl, init, settings);
  } catch (error) {
    throw new ServerConnection.NetworkError(error);
  }

  let data: any = await response.text();

  if (data.length > 0) {
    try {
      data = JSON.parse(data);
    } catch (error) {
      console.error('Not a JSON response body.', response);
    }
  }

  if (!response.ok) {
    throw new ServerConnection.ResponseError(response, data.message || data);
  }

  return data;
}