validateSearch using async data
Hello,
I am building an app that rely on the selected project stored as “project_id” as a root search.
The project_id is a string but also requires additional validation (does the user has access to this project ?) that will be done in my root component directly.
If no project_id is passed, I want to default to the first project_id returned by the API for this user.
Is validateSearch a good place to query data and set the default search asynchronously ? Is there a better pattern ?
Thanks
2 Replies
fair-rose•2y ago
Currently,
validateSearch cannot be async.
I also would not use it in the way you described it.
Instead, I would make the project_id search param optional, and then check e.g. in the loader or in the component if it is set or not, and if not, call the API and redirect to the first project_idextended-salmonOP•2y ago
That makes sense, thanks !