export const getServerSideProps: GetServerSideProps = async (context) => {
// await Moralis.start({ serverUrl, appId, masterKey })
const id = context.query.id;
//const res = await Moralis.Cloud.run('Tweets)
const res = await fetch(`https://5va56q8lbgwp.usemoralis.com:2083/server/functions/Tweets?_ApplicationId=LzXKHOSiXMjAf3oBj7iIREKdV1IE0APcoMgfihNE`)
const data = await res.json()
console.log(JSON.stringify(data))
if (!data) {
return {
redirect: {
destination: '/',
permanent: false,
statusCode: 301
},
}
}
return {
props: { data }, // will be passed to the page component as props
}
}
my cloud function
Moralis.Cloud.define("Tweets", async function (request) {
const query = new Parse.Query("Tweets");
const result = await query.find({ useMasterKey: true });
return result;
});