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.
@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.