I am trying to fetch my own data before rendering my application. Fortunately, Next.js provides getStaticProps()
for fetching data.
I am currently using fs
module to fetch my data from json file in local directory.
export async function getStaticProps() {
const rawData = fs.readFileSync('./dataset/test.json');
const data = modifyData(JSON.parse(rawData));
return {
props: {
data
}
}
}
But the problem is, for securing my raw data, I didn't push them to the GitHub remote repository. Forgetting this, when I tried to deploy my app through vercel, it couldn't read any data from my GitHub repository as the repository does not contain any data to fetch from...
I don't want to push my raw data to GitHub.
I would like to know
If there are some fundamentals of Next.js or any other I missed, please let me know and correct me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.