burnstony#1975B
Convex Community14mo ago
10 replies
burnstony#1975

httpAction

can't seem to get the body inside an http post action

https://docs.convex.dev/functions/http-actions

body is undefined everytime?

TS
import { httpAction } from "./_generated/server";
import { internal } from "./_generated/api";

export const postMessage = httpAction(async (ctx, request) => {
const { author, body } = await request.json();

await ctx.runMutation(internal.messages.sendOne, {
body: Sent via HTTP action: ${body},
author,
});

return new Response(null, {
status: 200,
});
});
HTTP actions allow you to build an HTTP API right in Convex!
HTTP Actions | Convex Developer Hub
Was this page helpful?