diff --git a/backend/web-bff/App/fetch.js b/backend/web-bff/App/fetch.js index b32fc34d..5587ce1e 100644 --- a/backend/web-bff/App/fetch.js +++ b/backend/web-bff/App/fetch.js @@ -35,11 +35,17 @@ async function fetch(endpoint, accessToken, method, body, headers) { console.log(`${method} request made to ${BACKEND_API_ENDPOINT}/${endpoint} at: ` + new Date().toString()); try { - const response = await axios(config); - return await response.data; + const res = await axios(config) + return {code: res.status, data: res.data} } catch (error) { - throw new Error(error); + if (error.response) { + return {code: error.response.status, data: error.response.data} + } else { + throw Error(error); + } } + + } module.exports = fetch; diff --git a/backend/web-bff/App/routes/api.js b/backend/web-bff/App/routes/api.js index 06b8c476..b15647ae 100644 --- a/backend/web-bff/App/routes/api.js +++ b/backend/web-bff/App/routes/api.js @@ -25,7 +25,7 @@ router.all('/*', try { const response = await fetch( "api" + req.url , req.session.accessToken, req.method, req.body, req.headers) - res.send(response) + res.status(response.code).send(response.data) } catch(error) { next(error); }