help to filter data from Strapi by one category or more
Unanswered
Dutch Shepherd posted this in #help-forum
Dutch ShepherdOP
Hello! I'm using Next.js 14 and I'm new to Strapi. I'm having trouble finding a proper response, so I'm seeking help here.
Here's how I'm fetching Strapi data on the server page:
I have a child component with a list of buttons for each available category, and another child component with a list of blogs.
How can I filter the blogs from the page using the buttons in the child component? How can I change the fetch parameters from here ? and what exactly do I need to change? I'm confused.
Thanks for your help
Here's how I'm fetching Strapi data on the server page:
const fetchBlogs = async (params) => {
const reqOptions = {
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
},
};
const request = await fetch(`${config.api}/api/blogs?populate=*&${params}`, reqOptions);
const response = await request.json();
return response;
};
const page = async () => {
const blogs = await fetchBlogs();
};I have a child component with a list of buttons for each available category, and another child component with a list of blogs.
How can I filter the blogs from the page using the buttons in the child component? How can I change the fetch parameters from here ? and what exactly do I need to change? I'm confused.
Thanks for your help