I have a dynamic page connected to a dataset.
A boolean field in that dataset is called “Submitted”.
I want to use an afterRouter hook to check the value of Submitted, and if true then redirect to a different page.
Using the Wix example:
import {ok} from 'wix-router';
export function myRouter_afterRouter(request, response) {
if(response.status === 200 && response.page === "horizontal-pic") {
if(response.data.picture.orientation === "vertical")
return ok("vertical-pic", response.data, response.head);
else
return response;
}
return response;
}
I assumed I could modify to this:
import {ok} from 'wix-router';
export function natp_afterRouter(request, response) {
if (response.data.submitted === true) {
return ok("NATP No Edit (ID)", response.data, response.head);
} else {
return response;
}
}
However, inspecting the Site Events dashboard tells me that response.data.submitted is consistently returning null.
From the afterRouter api:
“The afterRouter hook is a data binding router hook that is triggered after the router with the specified prefix has bound the data, but before the page is displayed. The router can be a code router or the data binding router that binds data to a dynamic page.”
So my question is - how can I inspect the data bound to the page and determine the value of the field “Submitted”?