i have the following issue with getStaticPaths of Next.JS:
TypeError: cias.map is not a function https://i.stack.imgur.com/IVZDp.png
Can someone help me with this, please?
Code:
import React from 'react'
import { Container } from '../../../styles/pages/container'
import { GetStaticProps, GetStaticPaths } from 'next'
import fetch from 'isomorphic-unfetch'
export const getStaticPaths: GetStaticPaths = async () => {
const res = await fetch('http://localhost:3000/api/infocadcias')
const cias = await res.json()
const paths = cias.map(cia => ({
params: { id: cia.ID.toString() }
}))
return { paths, fallback: false }
}
export const getStaticProps: GetStaticProps = async ({ params }) => {
const res = await fetch(`http://localhost:3000/infocadcias/${params.id}`)
const cia = await res.json()
return cia
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function InfoCia({ cia }) {
return (
<Container>
<ul>
{cia.map(p => (
<li className="cia" key={p.ID}>
<span>Name: {p.Name}</span>
</li>
))}
</ul>
</Container>
)
}