mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Update 21-httprequest.js
This commit is contained in:
parent
6c75baecb2
commit
21ce23d27d
@ -28,6 +28,7 @@ module.exports = function(RED) {
|
||||
var nodeUrl = n.url;
|
||||
var isTemplatedUrl = (nodeUrl||"").indexOf("{{") != -1;
|
||||
var nodeMethod = n.method || "GET";
|
||||
var usePayloadAsParameters = n.usePayloadAsParameters;
|
||||
if (n.tls) {
|
||||
var tlsNode = RED.nodes.getNode(n.tls);
|
||||
}
|
||||
@ -199,6 +200,22 @@ module.exports = function(RED) {
|
||||
}
|
||||
opts.body = payload;
|
||||
}
|
||||
|
||||
if (method == 'GET' && typeof msg.payload !== "undefined" && usePayloadAsParameters) {
|
||||
if (typeof msg.payload === "object") {
|
||||
if(opts.url.indexOf("?") !== -1) {
|
||||
opts.url += "&" + querystring.stringify(msg.payload);
|
||||
} else {
|
||||
opts.url += "?" + querystring.stringify(msg.payload);
|
||||
}
|
||||
|
||||
} else {
|
||||
//I'm not sure where to set "httpin.errors.unvalid-payload" :(
|
||||
node.error(RED._("httpin.errors.invalid-payload"),msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// revert to user supplied Capitalisation if needed.
|
||||
if (opts.headers.hasOwnProperty('content-type') && (ctSet !== 'content-type')) {
|
||||
opts.headers[ctSet] = opts.headers['content-type'];
|
||||
|
Loading…
Reference in New Issue
Block a user