I used the provided example from Vercel documentation, to fetch the data from MongoDB after every 15 seconds, but unfortunately the function doesn't work. What should I do to make it work as expected?
export async function getStaticProps() {
const allData = getSortedData();
const client = await clientPromise;
const isConnected = await client.isConnected();
const alerts = await client.db()
.collection("alerts")
.find({})
.limit(6)
.toArray();
const alertsData = JSON.parse(JSON.stringify(alerts));
return {
props: {
allData,
isConnected,
alertsData
},
revalidate: 15,
};
}