Skip to content

Commit

Permalink
Updated Api Routes Middleware example to use getServerSideProps (#11128)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgranados committed Mar 20, 2020
1 parent f25f9b8 commit 8724b3c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/api-routes-middleware/pages/index.js
Expand Up @@ -2,11 +2,11 @@ import fetch from 'isomorphic-unfetch'

const Index = ({ cookie }) => <div>{`Cookie from response: ${cookie}`}</div>

Index.getInitialProps = async () => {
export async function getServerSideProps() {
const response = await fetch('http://localhost:3000/api/cookies')
const cookie = response.headers.get('set-cookie')

return { cookie }
return { props: { cookie } }
}

export default Index

0 comments on commit 8724b3c

Please sign in to comment.