Skip to content

SvelteKit "handleSubmit" omits data #1270

@zicho

Description

@zicho

Description

I cannot get "data" to get passed along to the server when using sveltekit. I am trying this:

I set the "useChat" up on my +page.svelte

const { input, handleSubmit, messages } = useChat();

My submit handler:

function submitHandler(event: any) {
  event.preventDefault();
  handleSubmit(event, {
    data: {
      test: 'data'
    }   
  });
}

And my server:

export const POST = (async ({ request }) => {
  try {
    const jsonData = await request.json();

    console.dir(jsonData); // "data" object is missing from here. i only have "messages"

Based on this React example I also tried:

<form
    on:submit={(e) => {
    handleSubmit(e, {
      data: {
        test: 'data'
      }
    });
  }}
>

but "data" is still not available in +server.ts endpoint

Code example

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions