Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import React from 'react'
function Error({ statusCode }) {
return (
<>
<h1>{statusCode}</h1>
<h2>This is the Next.js _error.js page</h2>
<p>Choose the status code by changing the url param above</p>
<p>
This page supports the 7.x.x status code range{' '}
<a href="https://github.com/joho/7XX-rfc">
https://github.com/joho/7XX-rfc
</a>
</p>
</>
)
}
Error.getInitialProps = ({ res, err }) => {
const statusCode = err.statusCode || 500
res.statusCode = statusCode
return { statusCode }
}
export default Error
import React from 'react'
import Link from 'next/link'
import fetch from 'node-fetch'
import Router from 'next/router'
function Index({ stars }) {
return <div>we always throw :)</div>
}
export async function getServerSideProps({ query }) {
const error = new Error('lalalala')
console.log('query', query)
error.statusCode = Number(query.statusCode) || 500
throw error
}
export default Index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.