JSON Parse Error converts the msg object to string

I'm using the http request node and sometimes I get this error "JSON Parse Error", maybe because the server is down or something. But whenever that happens the node converts the msg object to a string. Thus losing all the other properties.

How can I avoid this from happening?

EDIT: I actually captured the error:

API GET,"Error: socket hang up"

1 Like

I don't think it should wipe out other msg properties... msg.payload is the only property updated and it contains the result of the call. (that is in this case just the error string).
If it had succeeded then the payload would have been a complete new object so would only have the properties returned.
An easy test would be to check if the returned payload was a string or an object.
What other properties are you expecting ?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.