Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions apps/backend/source/controllers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ export class SharedController {
.get(FIAT_RATE_API + req.params.fiatCurrency)
.then((response: any) => {
logger.info('Fiat Response: ' + JSON.stringify(response?.data));
const fiatLowerCase = req.params.fiatCurrency.toLowerCase();
if (response.data?.bitcoin && response.data?.bitcoin[fiatLowerCase]) {
return res.status(200).json({ rate: response.data?.bitcoin[fiatLowerCase] });
} else {
return handleError(
new APIError(HttpStatusCode.NOT_FOUND, 'Price Not Found'),
req,
res,
next,
);
if (response.data?.bitcoin) {
const bitcoinValues = Object.values(response.data.bitcoin);
const rate = bitcoinValues[0];
if (rate === undefined) {
return handleError(
new APIError(HttpStatusCode.NOT_FOUND, 'Price value not found'),
req,
res,
next,
);
}
return res.status(200).json({ rate });
}
})
.catch(err => {
Expand Down