I am using getServerSideProps to make backend request for data
export async function getServerSideProps(context) {
const res = await MachineService.listOrgs()
const organizatons = [
'csdc3443dsvk',
'csddscd3443dsvk',
'12dc3443dsvk',
'csdc3443ds56k',
'csdc3443ds67',
]
return {
props: { organizatons }, // will be passed to the page component as props
}
}
Here is my listOrgs code
const listOrgs = async (nextToken, limit) => {
return new Promise(async (resolve, reject) => {
fetch('http://localhost:3000/api/organizations/')
.then(res => res.json())
.then((result) => {
resolve({ Organizations: result })
})
.catch((error) => reject(error))
});
}
export default listOrgs;
making request to http://localhost:3000/api/organizations/ from browser returns me expected data but calling it from server side returns above error