From b0ce56a035f78b5b6eec1672124743072da067ad Mon Sep 17 00:00:00 2001 From: Divlo Date: Thu, 19 Mar 2020 23:21:20 +0100 Subject: [PATCH] backend: Small Hotfix --- backend/assets/functions/main/convertCurrency.js | 3 +++ backend/assets/functions/main/convertTemperature.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/assets/functions/main/convertCurrency.js b/backend/assets/functions/main/convertCurrency.js index 73b92cb..110b766 100644 --- a/backend/assets/functions/main/convertCurrency.js +++ b/backend/assets/functions/main/convertCurrency.js @@ -20,6 +20,9 @@ exports.convertCurrencyOutput = ({ res, next }, argsObject) => { axios.get(`https://api.exchangeratesapi.io/latest?base=${baseCurrency}`) .then((response) => { const rate = response.data.rates[finalCurrency]; + if (!rate) { + return errorHandling(next, { message: "La devise n'existe pas.", statusCode: 404 }); + } const result = rate * number; const dateObject = new Date(response.data.date); const year = dateObject.getFullYear(); diff --git a/backend/assets/functions/main/convertTemperature.js b/backend/assets/functions/main/convertTemperature.js index 8cf2339..dfadd24 100644 --- a/backend/assets/functions/main/convertTemperature.js +++ b/backend/assets/functions/main/convertTemperature.js @@ -48,5 +48,5 @@ exports.convertTemperatureOutput = ({ res, next }, argsObject) => { return errorHandling(next, generalError); } - return res.status(200).json({ result }); + return res.status(200).json(result); } \ No newline at end of file