I'm trying to do getStaticPaths and getStaticProps but I'm always getting an error that the paths is undefined in getStaticPaths. Next version is currently on 10.0.3.
This is the error message
Error: Invalid value returned from getStaticPaths in /properties/[id]. Received undefined Expected: { paths: [], fallback: boolean }
Here's my code
export async function getStaticPaths() {
try {
const properties = await api.get('/properties', {
headers: generateAuthHeaders(null, 'application/json', API_TOKEN)
})
const paths = properties.res.data.propertyDetails.map(value => {
return {
params: { id: value.id }
}
})
return { paths, fallback: false }
} catch (er) {
// do nothing
}
}
export async function getStaticProps({ params }) {
try {
const properties = await api.get(`/properties/${params.id}`, {
headers: generateAuthHeaders(null, 'application/json', API_TOKEN)
})
return {
props: {
propertyDetails: JSON.parse(JSON.stringify(properties.data.properties))
}
}
} catch (er) {
return {
props: { propertyDetails: false }
}
}
}