Skip to content

Instantly share code, notes, and snippets.

@zaetrik
Created April 19, 2020 10:43
Show Gist options
  • Save zaetrik/b733dbccd2b9f530e1f45a44f989eedc to your computer and use it in GitHub Desktop.
Save zaetrik/b733dbccd2b9f530e1f45a44f989eedc to your computer and use it in GitHub Desktop.
Functional JS API Requests - Failed Request
getExchangeRatesForCountry(CountryCode.GGG).then(console.log);
// => It returns our failed request
// The error is wrapped inside of a TaskEither monad
{
_tag: 'Left',
left: Error: Request failed with status code 400
at createError (/Users/code/javascript/functional-js/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users/code/javascript/functional-js/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/Users/code/javascript/functional-js/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:333:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment