This was the root cause which prompted me to consider #22
The library attempts to parse the body of every response from sematext without first checking that the overall request was successful.
The issue is on this line: https://github.com/sematext/logsene-js/blob/master/index.js#L528
The library should first check that the response is within the 200 > 299 range, and perhaps even then, safely check if res.body.items exists before trying to iterate it.
Additionally, mutating the response object here https://github.com/sematext/logsene-js/blob/master/index.js#L515 is not a great idea and should probably be assigned to a new variable.
I'll fix this as part of the work for #22