File tree Expand file tree Collapse file tree
apps/backend/source/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff 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 => {
You can’t perform that action at this time.
0 commit comments