Fetching single post data using getServerSideProps – Nextjs


Ask Question

export async function getServerSideProps({ params }) {
    // Call external API from here directly
    const response = await fetch(`http://localhost:1337/categories?slug=${params.slug}`)
    const data = await res.json()

    return {
        props: { menuItems: data }
    }
}

Leave a comment