multiple requests being made
Answered
johndoe7144 posted this in #help-forum
I switched from a client side component to a server side one and this page keeps making a lot of requests, is it normal?
const fetchSkills = async () => {
const res = await fetch("http://localhost:3000/api/sanity/skills");
const data = await res.json();
const skills = data?.filter((item) => item._type === "skills")[0].skills;
return skills;
};
const Skills = async () => {
const skills = await fetchSkills();
return (
<>
<div className="text-center"></div>
<h1 className="text-3xl font-bold">Skills</h1>
<p className="text-gray-600 dark:text-gray-400">
A list of all the skills I've learned.
</p>
<div className="grid grid-cols-2 gap-4">
{skills.map((skill, index) => (
<div
key={index}
className="p-4 bg-white dark:bg-gray-800 rounded-lg shadow-md"
>
<h3 className="text-2xl font-bold">{skill}</h3>
</div>
))}
</div>
</>
);
};
export default Skills;Answered by joulev
this is because you are still running this component as a client component. Did you import this into a client component?
3 Replies
@johndoe7144 I switched from a client side component to a server side one and this page keeps making a lot of requests, is it normal?
js
const fetchSkills = async () => {
const res = await fetch("http://localhost:3000/api/sanity/skills");
const data = await res.json();
const skills = data?.filter((item) => item._type === "skills")[0].skills;
return skills;
};
const Skills = async () => {
const skills = await fetchSkills();
return (
<>
<div className="text-center"></div>
<h1 className="text-3xl font-bold">Skills</h1>
<p className="text-gray-600 dark:text-gray-400">
A list of all the skills I've learned.
</p>
<div className="grid grid-cols-2 gap-4">
{skills.map((skill, index) => (
<div
key={index}
className="p-4 bg-white dark:bg-gray-800 rounded-lg shadow-md"
>
<h3 className="text-2xl font-bold">{skill}</h3>
</div>
))}
</div>
</>
);
};
export default Skills;
this is because you are still running this component as a client component. Did you import this into a client component?
Answer
i dont think so, let me check tho
ah im stupid lol 😅