Created
April 19, 2020 10:47
-
-
Save zaetrik/df85855ca06da98f51e368163b650753 to your computer and use it in GitHub Desktop.
Functional JS API Requests - Validating the API Response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateExchangeRates = (countryCode: CountryCode) => ( | |
response: ExchangeRates | |
): either.Either<Error, ExchangeRates> => { | |
return response.base === countryCode | |
? either.right(response as ExchangeRates) | |
: either.left( | |
Error( | |
`Invalid exchange rates data! Expected ${countryCode} but got ${response.base}` | |
) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment