From bd6d3119ae760f8e1baaaaeed20121f1bae24dbd Mon Sep 17 00:00:00 2001 From: Jesse Egbosionu Date: Sat, 21 Dec 2024 19:04:35 +0100 Subject: [PATCH] chore: fix tap tap --- pages/api/v1/rates.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pages/api/v1/rates.js b/pages/api/v1/rates.js index a7d2a0c..7103c56 100644 --- a/pages/api/v1/rates.js +++ b/pages/api/v1/rates.js @@ -40,14 +40,23 @@ export default async (req, res) => { ) .then((response) => response.json()) .then((result) => { - const fxRate = result.availableCountries[1].corridors.find( - (corridors) => { - return corridors.countryDisplayName == "Nigeria" - } + const nlRates = result.availableCountries.find((availableCountry) => { + return availableCountry.isoCountryCode == "NL" + } ); + let fxRate = 0 + if (nlRates) { + for (let corrridor of nlRates.corridors) { + if (corrridor["isoCountryCode"] === "NG") { + fxRate = corrridor["fxRate"] + break + }; + } + } + return { - rate: fxRate["fxRate"], + rate: fxRate, provider: "TapTap", bestRate: false, href: "https://www.taptapsend.com/",