Error on fetching data from server component
Unanswered
Singapura posted this in #help-forum
SingapuraOP
When i try to fetch an api from server component i get this error:
however the api is working, and when i try from client component it works fine
here is the server component code
Fetch failed: TypeError: fetch failed
at async Page (D:\Programming\react\course practice\next_projects\my-app\.next\dev\server\chunks\ssr\[root-of-the-server]__193ccffa._.js:30:21) {
[cause]: Error: read ECONNRESET
at ignore-listed frames {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
}however the api is working, and when i try from client component it works fine
here is the server component code
export default async function Page() {
try {
const response = await fetch("https://jsonplaceholder.typicode.com/users");
const data = await response.json();
console.log(data);
} catch (err) {
console.error("Fetch failed:", err);
}
return <h1>test</h1>;
}