async function postReportWebcompatIssue()

in src/js/background/background.js [107:137]


async function postReportWebcompatIssue(description) {
  const { relayApiSource } = await browser.storage.local.get("relayApiSource");  
  
  if (!relayApiSource) {
    return;
  }

  const headers = await createNewHeadersObject({auth: true});
  const reportWebCompatResponse = `${relayApiSource}/report_webcompat_issue`;

  const apiBody = {
    issue_on_domain: description.issue_on_domain,
    email_mask_not_accepted: description.email_mask_not_accepted,
    add_on_visual_issue: description.add_on_visual_issue,
    email_not_received: description.email_not_received,
    other_issue: description.other_issue,
    user_agent: description.user_agent
  };

  const newReportedIssueFetch = await fetch(reportWebCompatResponse, {
    mode: "same-origin",
    method: "POST",
    headers: headers,
    body: JSON.stringify(apiBody),
  });

  // NOTE: This API call does NOT return a JSON object. 
  // Returning the status is enough to run pass/fail logic for the submission
  return newReportedIssueFetch.status;

}