INNER CODE UNIT · JavaScript
getStaticProps
hygraph/hygraph-examples · using-order-by-filter/pages/index.js:25
export const getStaticProps = async () => {
const initialData = await hygraph.request(GetProductsQuery);
return {
props: {
initialData,
},
revalidate: 30,
};
};
export default function IndexPage({ initialData }) {
const [orderBy, setOrderBy] = useState('price_ASC');
const { data } = useSWR(
[GetProductsQuery, orderBy],
(query, orderBy) => hygraph.request(query, { orderBy }),
{