Closed danilowanner closed 8 years ago
@danilowanner Can we check to see when it returns JSON and when it returns HTML. We need to convert to JSON when needed.
I thought about that. We could try and parse JSON and if it fails catch the error. But since we are going to display an error, we convert to a string anyways right afterwards.
The node console would show the following, if we were to log the parsed JSON:
[Error: [object Object]]
When we log the body directly we get:
[Error: {"error":{"code":404,"message":"Not Found"}}]
Fixed in #12
I had to make another small change.
Sometimes netatmo fails to return JSON when an error occurs. Previously this caused the package to crash. The change should remedy this.