T
TanStack2mo ago
old-apricot

Only generate ServerRoute with DELETE method will make 404 error

import...

export const ServerRoute = createServerFileRoute(
"/admin/_protected/generus/_index/$id",
).methods({
DELETE: async ({ params }) => {
const data = await prisma.generus.delete({ where: { id: params.id } });
console.log("click");
return formatResponse(
true,
"Berhasil menghapus data Generus",
{ items: data, meta: { total: 1, page: 0, limit: 1, totalPages: 1 } },
null,
);
},
});

// Format Response
export function formatResponse<T>(
success: boolean,
message: string,
data: { items: T; meta: Pagination } | null,
error: ErrorResponse | null,
): ResponseBase<T> {
return {
success,
message,
data,
error,
};
}
import...

export const ServerRoute = createServerFileRoute(
"/admin/_protected/generus/_index/$id",
).methods({
DELETE: async ({ params }) => {
const data = await prisma.generus.delete({ where: { id: params.id } });
console.log("click");
return formatResponse(
true,
"Berhasil menghapus data Generus",
{ items: data, meta: { total: 1, page: 0, limit: 1, totalPages: 1 } },
null,
);
},
});

// Format Response
export function formatResponse<T>(
success: boolean,
message: string,
data: { items: T; meta: Pagination } | null,
error: ErrorResponse | null,
): ResponseBase<T> {
return {
success,
message,
data,
error,
};
}
and sometimes when im save this file it will make change where that path not be generating, it should be return a format response, how do i do like that?
2 Replies
old-apricot
old-apricotOP2mo ago
and i was using defaultnotfound component in my router root
reduced-jade
reduced-jade2mo ago
unclear what this is about. please provide a complete example project

Did you find this page helpful?