import fetch from 'node-fetch' const Person = ({ data, status }) => status === 200 ? (
Name | Height | Mass | Hair color | Skin color | Eye color | Gender |
---|---|---|---|---|---|---|
{data.name} | {data.height} | {data.mass} | {data.hair_color} | {data.skin_color} | {data.eye_color} | {data.gender} |
{data.message}
) export async function getStaticPaths() { const response = await fetch('http://localhost:3000/api/people') const data = await response.json() const paths = data.map(person => ({ params: { id: person.id, }, })) return { paths, fallback: false } } export async function getStaticProps({ params }) { const response = await fetch(`http://localhost:3000/api/people/${params.id}`) const data = await response.json() return { props: { data, status: response.status, }, } } export default Person