Relative Content

Tag Archive for jsontypescriptnextjs-dynamic-routing

SyntaxError: Unexpected non-whitespace character after JSON at position 4 Typescript

// getStaticPaths function export const getStaticPaths: GetStaticPaths = async () => { const res = await fetch(“http://localhost:5000/products”); const products = await res.json(); const paths = products.map((product: { _id: string }) => ({ params: { productid: product._id }, })); return { paths, fallback: false }; }; export const getStaticProps: GetStaticProps = async (context) => { try […]