I have the following server rendered component in the NextJS 13 experimental app directory:
const Example = async () => {
const { data, error } = await fetchData()
return null
}
const fetchData = async () => {
try {
const response = await fetch(`${process.env.RESTAPI_URI}/data?populate=*`)
const json = await response.json()
return {
data: json.data,
}
} catch (err: any) {
return {
data: [],
error: err?.message,
}
}
}
export default Example
I want to make it so that if the fetch fails, the HTTP response code sent to the user is something other than 200. Is this possible?