This is my code in my +page.server.js:
export const actions = {
default: async ({request}) => {
const data = await request.formData();
const ln = data.get('lastname');
.....
}
};
export function load() {
if (!db) throw error(404);
return {
todos: db.getTodos()
}
}
My question: how do I use the actions object output variable for filtering what I get from db.getTodos() in the load function?
I can implement the filter on the front-end in +page.svelte by using a bind:value on the variable, but I would rather filter on the server side.
The easiest way to return the correct results would be to just return them directly via the form action's data. If you want to use
load, there are three options I can think of:I would not really recommend the latter two options, as they make things stateful and thus more messy.
For the redirect you can use query parameters or a different route with route parameters.
Here would be a simple example using the current route & query parameters: