skip to Main Content

I'm unable to get the id from the JSON object in Next Js API – Reactjs

data.js inside API folder export default { Trending : [ { "data":[ { "id":1, "attributes":{ "Title":"Technical", "slug":"blog", "Description":"#PythonnPythonisasimplelanguageforstarters.", "Date":"2023-03-06", "Author":"Ankush", "createdAt":"2023-03-06T03:11:19.450Z", "updatedAt":"2023-03-06T03:11:21.956Z", "publishedAt":"2023-03-06T03:11:21.951Z", "locale":"en" } } ], "meta":{ "pagination":{ "page":1, "pageSize":25, "pageCount":1, "total":1 } } } ] } trending.js import…

VIEW QUESTION

How does NextJS execute the code inside these functions with and without async? – Javascript

Function with async: export async function getPostData(id) { const fullPath = path.join(postsDirectory, `${id}.md`); const fileContents = fs.readFileSync(fullPath, 'utf8'); const matterResult = matter(fileContents); return { id, ...matterResult.data, }; } Function without async: export function getPostData(id) { const fullPath = path.join(postsDirectory, `${id}.md`);…

VIEW QUESTION
Back To Top
Search