Check if error is a string or an object
Closed this issue · 2 comments
dvh commented
Posting a contact
with a duplicate customer_id
results in the following API response:
422: Unprocessable entity
{
"error": {
"customer_id": [
"already exists"
]
}
}
Unlike other error messages from the Moneybird API, the error
is an object instead of a string here. This breaks your code, because it seems that https://github.com/renedx/node-moneybird/blob/master/src/libs/https.js#L31 assumes error
is always a string.
rdzar commented
Thanks for your detailed bug-report! This has been fixed in 1.0.2
on NPM.
An example of usage can be found here:
https://github.com/renedx/node-moneybird#example-create-contact-with-fields-error
dvh commented
Great, thanks!