Hello! I want to use the usernames of the database as “path” to map the routes of my NEXT JS app. Im fetching an object that contains the usernames of all users registered on my Moralis server using a cloud function that looks like this:
function getUsers() {
const query = new Parse.Query("User");
query.limit(1000);
const result = query.find({ useMasterKey: true });
return result;
}
Then, in my app component I filter the previous object to obtain only the usernames:
async function getCloud() {
const cloud = await Moralis.Cloud.run("cloud");
return cloud.map((ParseUser: { attributes: { username: any } }) => ({
params: {
username: ParseUser.attributes.username
}
}));
}
After that, I try to use NEXT’s native function to obtain the username from the params of this object:
export const getStaticPaths: GetStaticPaths = async () => {
const paths = await getCloud();
return {
paths,
fallback: false
};
};
The getStaticPaths
function is throwing the above error but I don’t really know the proper way to initialize parse (as far as Im concerned Moralis is a fork from parse right?) so I think maybe you know better than me about this issue. Any help will be much appreciated!