Filtering using an API with Server Side Components
Unanswered
Barrow's Goldeneye posted this in #help-forum
Barrow's GoldeneyeOP
I have an endpoint that allows me to make get todos and also let me filter the by some params. In my next.js application I'm sotoring the data in a
const todos_list = getTodos();. I'm using the async notation in my component in order to fetch in the server, let's suppose that I have a button and when I press that button I want to update my list to only fetch the todos that are finished. How can I achieve that without having to use the useState in my todos_list?2 Replies
@Barrow's Goldeneye I have an endpoint that allows me to make get todos and also let me filter the by some params. In my next.js application I'm sotoring the data in a const todos_list = getTodos();. I'm using the async notation in my component in order to fetch in the server, let's suppose that I have a button and when I press that button I want to update my list to only fetch the todos that are finished. How can I achieve that without having to use the useState in my todos_list?
European sprat
Maybe some combination of searchParams and server actions? Alternatively you do it in a client component to a route handler
Barrow's GoldeneyeOP
do you suggest to add the searchParams in the todosContainer?