So I have a page in my next.js project that gets two or more parameters. The code is simplified here but it's basically this one:
export async function getStaticPaths() {
const param1Data = await fetch('http://IP:PORT/getData/getPossibleParam1Ids');
const param2Data = await fetch('http://IP:PORT/getData/getPossibleParam2Ids');
const firstParams = await releasesData.json();
const secondParams = await buildsData.json();
const paramsArray = [];
firstParams.forEach((firstParam) => {
secondParams.forEach((secondParam) => {
paramsArray.push({ params: { params: [firstParam.id.toString(), secondParam.id.toString()] } })
});
});
return {
paths: paramsArray,
fallback: "blocking"
};
}
export const getStaticProps = async ({ params }) => {
const [param1, param2, extraParam] = params.params;
const url = `http://IP:PORT/getData/${param1}/${param2}`;
const res = await fetch(url);
const data = await res.json();
if (data.statusCode) {
return {
notFound: true
}
}
const myKey = data[0][extraParam].key;
const myData = data[2][myKey];
return {
props: {
toUseData: myData,
}
}
}
I'm trying to add sorting capabilities to the table but nothing works. The example I saw in nextui.org doesn't use getStaticProps() so I don't understand how to do it.