loggly / node-loggly-bulk

A client implementation for Loggly in node.js
https://www.loggly.com/docs/node-js-logs/
Other
20 stars 20 forks source link

Handling syntax error while parsing HTML response #18

Closed Shwetajain148 closed 7 years ago

Shwetajain148 commented 7 years ago

@mchaudhary @mostlyjason, This PR is to resolve the issue https://github.com/loggly/node-loggly-bulk/issues/17.

In this PR, I have put an if condition to check if the body contains some data and not undefined and also parse the body when the response code is 200 OK. When there is some error returned from the server in HTML form in the body and when it goes to parse, it throws a syntax error. So I am checking both the body and the response code to parse the body further.

Please review.