Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX
Created April 30, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaNdTriX/942e5d73f8dc995bd034f55d83b34cd3 to your computer and use it in GitHub Desktop.
Save HaNdTriX/942e5d73f8dc995bd034f55d83b34cd3 to your computer and use it in GitHub Desktop.
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