Blank screen on responses
You have blank screen on responses. Why?
Solution
It means that you are not returning a valid response for inertia. You should not return any JSON from your controllers.
How to fix it if I need data ?
You can return a inertia.render
function.
index_controller.ts
async index({ inertia, request }: HttpContext) {
const payload = await indexValidator.validate(request.all());
let products = await this.productService.getProducts();
return inertia.render("index", {
products: ProductPresenter.presentList(products),
referer: payload.referer
});
}
Another example:
async general({inertia, auth}: HttpContext) {
return inertia.render("dashboard/dashboard", {githubUsername: auth.user!.githubUsername});
}
//later, in the dashboard.tsx file, you can access the data like this
const Dashboard = (props: InferPageProps<DashboardController, 'general'>) => {
See Page props for more information.