Files
fefan/next/api/index.js
Julien Aldon fa3793a181
All checks were successful
Deploy Fefan / deploy (push) Successful in 4m40s
add(blockRenderer): add blockRenderer component to add link open to a new page
2026-04-21 15:44:01 +02:00

21 lines
515 B
JavaScript

import qs from 'qs';
async function getData(path, query) {
const queryString = qs.stringify(query);
const isServerSide = typeof window === 'undefined';
const res = await fetch(
`${
isServerSide
? (process.env.NEXT_PRIVATE_CONTENT_URI ??
'http://fefan-backend:1337/api')
: (process.env.NEXT_PUBLIC_CONTENT_URI ??
'https://content.fefan.fr/api')
}/${path}?${queryString}`,
{ cache: 'no-store' },
);
return await res.json();
}
export default getData;