async function GET()

in htdocs/js/selfserve.js [61:81]


async function GET(url, params, method = 'GET') {
  const xhrID = uuid();
  const parameters = params || {}; // We want a dict here
  const headers = new Headers();
  headers.append('X-Selfserve-WebUI', 'yes'); // Inform the backend that we will not accept a Realm response
  if (parameters.json) headers.append('Content-Type', 'application/json');

  const data = parameters.json ? JSON.stringify(parameters.json) : toFormData(parameters.data);
  log(`[${xhrID}] Sending ${method} XHR to URL ${url}`);
  const response = await fetch(url, {
    method,
    headers,
    body: data,
  });
  log(`[${xhrID}] Server responded to ${method} ${url} with status: ${response.status} ${response.statusText}`);
  if (response.status >= 502) { // Proxy error??
      // convert error response to JSON for easier handling
      return Response.json({"success": false, "message": response.statusText});
  }
  return response;
}