Reading the documentation of NextJs i noticed that this framework has this feature:
function Page({ data }) {
// Render data...
}
// This gets called on every request
export async function getServerSideProps() {
// Fetch data from external API
const res = await fetch(`https://.../data`)
const data = await res.json()
// Pass data to the page via props
return { props: { data } }
}
export default Page
So, this getServerSideProps
allows to make http requests using SSR approach.
Question: It is correct if i will say that SSR requests are available only for get
requests? I say this because only this function allows us to make SSR requests and i can not imagine how to make a POST request using NEXT JS, like the user submit a form and want to send on back-end, so how in this case to use getServerSideProps
? Also, it is correct that NEXTJs allows us to make SSR requests only within pages
but not components?