Build Error
Unanswered
Himalayan posted this in #help-forum
HimalayanOP
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED 127.0.0.1:3000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3000
}
I am getting this error while building my application
import Organizations from "../pages/Organizations";
async function getData() {
const res = await fetch(process.env.NEXT_PUBLIC_API_URL+"/api/getallorgs",{
method: "GET",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
},
});
if (!res.ok) {
throw new Error("Failed to fetch data");
}
return res.json();
}
const OrganizationsHomePage = async() => {
const data = await getData();
return (
<Organizations fetchedOrganizations={data.orgs}/>
)
}
export default OrganizationsHomePage
Here is my fetch request due to which the error is occuring
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED 127.0.0.1:3000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3000
}
I am getting this error while building my application
import Organizations from "../pages/Organizations";
async function getData() {
const res = await fetch(process.env.NEXT_PUBLIC_API_URL+"/api/getallorgs",{
method: "GET",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
},
});
if (!res.ok) {
throw new Error("Failed to fetch data");
}
return res.json();
}
const OrganizationsHomePage = async() => {
const data = await getData();
return (
<Organizations fetchedOrganizations={data.orgs}/>
)
}
export default OrganizationsHomePage
Here is my fetch request due to which the error is occuring