Apollon77 / daikin-controller-cloud

Connect and Control Daikin Cloud devices
MIT License
98 stars 25 forks source link

Handle responses without body #107

Closed ptz0n closed 1 year ago

ptz0n commented 1 year ago

What's the problem?

Making requests that responds with HTTP 200 without a body throws due to naive property reading.

TypeError: Cannot read property 'toString' of undefined

What's changed?

Inline checking that res.body is truthy before invoking res.body.toString. In the case that we don't get a response body, return true like we do for HTTP 204 responses.

How can this be verified?

Should no longer throw when receiving a HTTP 200 response without body. Tested successfully in my environment.

Apollon77 commented 1 year ago

Adjusted directly