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