SolidJSS
SolidJSโ€ข3y agoโ€ข
2 replies
oneiro

Set headers inside createServerAction$()

Hey folks,

I am currently trying to explicitely set my content type header to Content-Type: application/json; charset=utf-8 because of some encoding issues.
However I don't quite understand how I can do so inside a call of createServerAction$().

I tried to access responseHeaders from useRequest(), however they seem to be always undefined:

  const [chartData, submitChartOptions] = createServerAction$(
    async (opts: { type: ChartType; options: SubmitChartOptions }) => {
      const { responseHeaders } = useRequest();

      const result = await generateChartDataByType(opts);

      responseHeaders.set("Content-Type", "application/json; charset=utf-8");

      return result;
    }
  );


Any idea, what I am doing wrong here?

Thanks in advance
Was this page helpful?