The problem is that if an ID is not in the database it will return a 404 error, I tried to make a check in if the res.status == 404 but it returns the error before going to the validation.
export const getServerSideProps = async (context) => {
const { id } = context.query;
const res = await axios.get(`${process.env.API_URL}/user/jobs/${id}`); //if ID does not exists here returns an error an does not validate the below lines
if (res.status == 404) { //not check if the above request returns a 404
return {
notFound: true,
};
}
const jobs = res.data;
return {
props: {
jobs,
},
};
};