Skip to content

Commit ef5f1ae

Browse files
Fix build error due to request params strict typing
1 parent b115a71 commit ef5f1ae

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

apps/backend/source/controllers/shared.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,18 @@ export class SharedController {
7878
.get(FIAT_RATE_API + req.params.fiatCurrency)
7979
.then((response: any) => {
8080
logger.info('Fiat Response: ' + JSON.stringify(response?.data));
81-
const fiatLowerCase = req.params.fiatCurrency.toLowerCase();
82-
if (response.data?.bitcoin && response.data?.bitcoin[fiatLowerCase]) {
83-
return res.status(200).json({ rate: response.data?.bitcoin[fiatLowerCase] });
84-
} else {
85-
return handleError(
86-
new APIError(HttpStatusCode.NOT_FOUND, 'Price Not Found'),
87-
req,
88-
res,
89-
next,
90-
);
81+
if (response.data?.bitcoin) {
82+
const bitcoinValues = Object.values(response.data.bitcoin);
83+
const rate = bitcoinValues[0];
84+
if (rate === undefined) {
85+
return handleError(
86+
new APIError(HttpStatusCode.NOT_FOUND, 'Price value not found'),
87+
req,
88+
res,
89+
next,
90+
);
91+
}
92+
return res.status(200).json({ rate });
9193
}
9294
})
9395
.catch(err => {

0 commit comments

Comments
 (0)