#Weird Error | Extra, attributes from the server data-new-gr-c-s-check-loaded,data-gr-ext-installed

1 messages · Page 1 of 1 (latest)

modern crown
#

I have this weird error in my console all the time but not causing any issues, but now when a send a delete request using useFetcher I got this problem, SyntaxError: Unexpected end of JSON input, but all my loader returns a valid JSON from @remix-run/node.

   const fetcher = useFetcher();
   const handleDelete = () => {
    fetcher.submit(null, {
      method: "delete",
      action: `/expenses/${id}`,
    });
  };

--------------
<Button onClick={handleDelete} className="w-24 bg-red-400">
          Delete
</Button>

expenses/$id route :

  export async function action({ params, request }: ActionArgs) {
  const expenseId = params.id;
  invariant(expenseId, `expenseId not found`);

  if (request.method === "DELETE") {
    await deleteExpense(expenseId);
    return json(null,
      {
        status: 204,
      }
    );
  }
}
#

Weird Error | Extra, attributes from the server data-new-gr-c-s-check-loaded,data-gr-ext-installed

hoary ember
#

What if you submit {} instead of null?

modern crown
#

The problem is about the headers: {
"Content-Type": "application/json",
}, But I don't know why

#

But when If I use json({}) without the status code it's working fine '-'

hoary ember
#

return null should also work. Is the status code necessary?

modern crown
#

not necessary, but my mind can't accept why this work and this is not '-', but I think it's a good practice to return 204 on the delete operation.

#

even if it works without the status code, I still get the weird error in the console. Extra attributes from the server: data-new-gr-c-s-check-loaded,data-gr-ext-installed