Mr.BryM
Deno2y ago
Mr.Bry

[uncaught application error]: TypeError - ctx.request.body is not a function

.post("/savedata",async (ctx) => {
    if (!ctx.request.hasBody) {
        ctx.response.status = 400;
        ctx.response.body = { error: "No data provided" };
        return;
    }

    try {
        const formData = await ctx.request.body({ type: "form-data" });
        const CodeClient = formData.value.get("CodeClient");
        const username = formData.value.get("username");
        const password = formData.value.get("password");
        const repeat_password= formData.value.get("repeatPassword");
        const KodeActivation = formData.value.get("KodeActivation");

        console.log(
${username} ${password}
);


        ctx.response.body = "Data saved";
    } catch (error) {
        ctx.response.status = 500;
        ctx.response.body = { error: error.message };
    }
})


please help me😩
Was this page helpful?