HonoH
Honoβ€’16mo ago
JustUseFirefox

How to use Validator ? Context is not finalized

As soon as I try to use validator, Hono complains.

api-hono:dev: error: Context is not finalized. Did you forget to return a Response object or await next()?


app.post(
  '/',
  validator('form', (value, c) => {
    console.log("VALIDATOR")

    const body = value['body'];
    // if (!body || typeof body !== 'string') {
    //   return c.text('Invalid!', 400);
    // }

    // const parsed = customerFormSchema.safeParse(body);
    // if (!parsed.success) {
    //   console.log(401)
    //   return c.text('Invalid!', 401);
    // }
    // // parsed.data for body;

    return {
      body
    };
  }),
...


Any idea? :\

EDIT:
I'm using Superforms to send the request. Devtool says the data it is indeed Form Data.
If I replace form with json, it doesnt throw the error, but the value is empty
Was this page helpful?