SolidJSS
SolidJSโ€ข11mo agoโ€ข
8 replies
exercise

ERR_HTTP_HEADERS_SENT

import { APIEvent } from "@solidjs/start/server";

export async function POST(event: APIEvent) {
  const data = new FormData();
  data.set("message", "test");

  event.nativeEvent.respondWith(
    Response.json({ message: "Optimistically sent a message!" })
  );

  await fetch(`https://discord.com/api/v10/channels/CHANNEL/messages`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bot TOKEN`,
    },
    body: JSON.stringify({ content: String(data.get("message")) }),
  });
}
Was this page helpful?