Use api route in next build #13293
-
I call an api route in my getStaticProps. How do I make sure the server is started which serves the api route? it's unreachable. I want to use next export later. export const getStaticProps = async (ctx: NextPageContext) => {
const res = await protect<AxiosResponse, AxiosError>(
axios.get("http://localhost:3334/api/blogEntries")
)
let entries: BlogEntry[] = res.ok!.data
return {
props: { entries },
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I just found another issue and it seems it's not supported? How can I then access |
Beta Was this translation helpful? Give feedback.
-
The Next docs say:
https://nextjs.org/docs/basic-features/data-fetching#write-server-side-code-directly |
Beta Was this translation helpful? Give feedback.
The Next docs say:
https://nextjs.org/docs/basic-features/data-fetching#write-server-side-code-directly