Created
April 30, 2020 14:16
-
-
Save HaNdTriX/942e5d73f8dc995bd034f55d83b34cd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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