async function handleRequest(request) {
  let response;
  if (request.method === "GET") {
    const parsedURL = url.parse(request.url, true);
    const stringJson = parsedURL.query.json;
    if (stringJson === undefined) {
      return new Response("Expected JSON data in url for GET request", {
        status: 400,
      });
    }
    const json = JSON.parse(stringJson);
    if (json.chartType !== "boxplot") {
      return new Response(`Unsupported chartType: ${json.chartType}`, {
        status: 500,
      });
    }
    if (json.data == undefined) {
      return new Response(`Expected JSON field: data`, {
        status: 500,
      });
    }

    const output = ReactDOMServer.renderToStaticMarkup(
      <BoxPlotSVG
        data={json.data}
        labels={json.labels != undefined ? json.labels : []}
        title={json.title != undefined ? json.title : ""}
      />
    );
    console.log(output);
    response = new Response(output, {
      headers: {
        "Content-Type": "image/svg+xml",
      },
      status: 200,
    });
  } else {
    response = new Response("Expected GET", { status: 500 });
  }
  return response;
}
/**
 * Fetch and log a request
 * @param {Request} request
 */
Fetch and log a request
@param {Request} request
Fetch and log a request @param { Request } request
async function handleRequest(request) {
  let response;
  if (request.method === "GET") {
    const parsedURL = url.parse(request.url, true);
    const stringJson = parsedURL.query.json;
    if (stringJson === undefined) {
      return new Response("Expected JSON data in url for GET request", {
        status: 400,
      });
    }
    const json = JSON.parse(stringJson);
    if (json.chartType !== "boxplot") {
      return new Response(`Unsupported chartType: ${json.chartType}`, {
        status: 500,
      });
    }
    if (json.data == undefined) {
      return new Response(`Expected JSON field: data`, {
        status: 500,
      });
    }
    const output = ReactDOMServer.renderToStaticMarkup(
      <BoxPlotSVG
        data={json.data}
        labels={json.labels != undefined ? json.labels : []}
        title={json.title != undefined ? json.title : ""}
      />
    );
    console.log(output);
    response = new Response(output, {
      headers: {
        "Content-Type": "image/svg+xml",
      },
      status: 200,
    });
  } else {
    response = new Response("Expected GET", { status: 500 });
  }
  return response;
}
async function handleRequest ( request ) { let response ; if ( request . method === "GET" ) { const parsedURL = url . parse ( request . url , true ) ; const stringJson = parsedURL . query . json ; if ( stringJson === undefined ) { return new Response ( "Expected JSON data in url for GET request" , { status : 400 , } ) ; } const json = JSON . parse ( stringJson ) ; if ( json . chartType !== "boxplot" ) { return new Response ( ` ${ json . chartType } ` , { status : 500 , } ) ; } if ( json . data == undefined ) { return new Response ( ` ` , { status : 500 , } ) ; } const output = ReactDOMServer . renderToStaticMarkup ( < BoxPlotSVG data = { json . data } labels = { json . labels != undefined ? json . labels : [ ] } title = { json . title != undefined ? json . title : "" } / > ) ; console . log ( output ) ; response = new Response ( output , { headers : { "Content-Type" : "image/svg+xml" , } , status : 200 , } ) ; } else { response = new Response ( "Expected GET" , { status : 500 } ) ; } return response ; }
Fetch and log a request
 @param {Request} request
Fetch and log a request @param { Request } request