mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Handle 204 in httprequest JSON
If the http statusCode is 204 (Success, No Content) and the node return type is set to JSON this sets msg.payload as an empty json object so as to supress the JSON parse error
This commit is contained in:
parent
877aa75e4e
commit
2b01a3fcd3
@ -618,6 +618,7 @@ in your Node-RED user directory (${RED.settings.userDir}).
|
||||
msg.payload = msg.payload.toString('utf8'); // txt
|
||||
|
||||
if (node.ret === "obj") {
|
||||
if (msg.statusCode == 204){msg.payload= "{}"};
|
||||
try { msg.payload = JSON.parse(msg.payload); } // obj
|
||||
catch(e) { node.warn(RED._("httpin.errors.json-error")); }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user