diff --git a/pages/result/[pid]/[[...tid]].jsx b/pages/result/[pid]/[[...tid]].jsx index 4e4323a..e17ec95 100644 --- a/pages/result/[pid]/[[...tid]].jsx +++ b/pages/result/[pid]/[[...tid]].jsx @@ -26,17 +26,15 @@ export async function getServerSideProps({ query, locale }) { const [res, details, translations] = await Promise.all([ getResults( pid, - (res) => { - ok: true, res; - }, - (err) => ({ ok: false, err }) + (res) => ({ ok: true, res }), + (err) => { + return { ok: false, err: "Unknown error" }; + } ), getDetails( pid, - (res) => { - ok: true, res; - }, - (err) => ({ ok: false, err }) + (res) => ({ ok: true, ...res }), + (err) => ({ ok: false, err: "Unknown error" }) ), serverSideTranslations(locale, [], config), ]); @@ -52,7 +50,7 @@ export async function getServerSideProps({ query, locale }) { props: { title: details.title, numGrades: details.num_grades, - candidates: res, + candidates: res.res, pid: pid, ...translations, }, diff --git a/services/api.js b/services/api.js index da3e839..975a8a6 100644 --- a/services/api.js +++ b/services/api.js @@ -127,8 +127,7 @@ const getResults = (pid, successCallback, failureCallback) => { return response.json(); }) .then(successCallback || ((res) => res)) - .catch((err) => err) - .then(failureCallback || console.log); + .catch(failureCallback || ((err) => err)); }; const getDetails = (pid, successCallback, failureCallback) => { @@ -148,7 +147,7 @@ const getDetails = (pid, successCallback, failureCallback) => { return response.json(); }) .then(successCallback || ((res) => res)) - .catch(failureCallback || console.log); + .catch(failureCallback || ((err) => err)); }; const castBallot = (judgments, pid, token, callbackSuccess, callbackError) => {