I’ve been sitting here for 2 hours and I don’t understand a damn thing. I have searched the whole internet and can’t understand why getStaticProps doesn’t work. First I used it at the component level and it didn’t work. Then I found an article that said it should be used at the page level. That’s what I did, but it didn’t work for me again. I have Next version 14, maybe something has changed in this version or I’m blind and dumb.
app/(group)/rooms
import { RoomsPage } from '@/page/Rooms'
import { getCards } from '@/shared/api'
import { IRoomsCardAllData } from '@/shared/types'
import { GetStaticProps, Metadata } from 'next'
import { FC } from 'react'
export const getStaticProps: GetStaticProps = async () => {
try {
const res = await getCards()
return { props: { roomsData: res.data } }
} catch (err) {
console.error(err)
return { props: { roomsData: [] } }
}
}
export const metadata: Metadata = {
title: 'Guest House | Номера',
}
interface Props {
roomsData: IRoomsCardAllData[]
}
const Rooms: FC<Props> = ({ roomsData }) => {
return <RoomsPage roomsData={roomsData} />
}
export default Rooms
Everything that is in getStaticProps does not seem to work. No errors are displayed, nor console.log is processed. I don’t know what to think?
Джамбулат Кагерманов is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.