ActiveCampaign / activecampaign-api-nodejs

Node.js wrapper for the ActiveCampaign API
MIT License
39 stars 36 forks source link

Not a JSON Object #28

Closed adamkchew closed 6 years ago

adamkchew commented 8 years ago

I'm able to make API call's to the api but when there is a error response, it's not in a JSON format. Could we update the API to return in a JSON error format?

The exception isn't helpful as I don't know the reason for the error in the first place.

var api_request = new RSVP.Promise(function(fulfill, reject) { request(request_options, function(error, response, body) { try { JSON.parse(body); } catch (e) { reject("Not a valid JSON object.") return; }

zdila commented 7 years ago

We've encountered the same problem today. Server responded with HTTP 503 and HTML page instead of JSON. We had to hack the library code to find this out.

ziedmahdi commented 7 years ago

Yeah me too, same problem today. the try catch provided by @adamkchew will help

ziedmahdi commented 7 years ago

@zdila this error was corrected in current version (1.2.3). Maybe you are using an outdated version.

zdila commented 7 years ago

@ziedmahdi Thanks for info. In production we unfortunately use 1.2.2.