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,
}
);
}
}