diff --git a/nodes/woocommerce-config.js b/nodes/woocommerce-config.js index 735fb30..2b4382a 100644 --- a/nodes/woocommerce-config.js +++ b/nodes/woocommerce-config.js @@ -9,8 +9,8 @@ module.exports = function (RED) { const node = this; node.baseUrl = (config.baseUrl || "https://example.com/wp-json/wc/v3").replace(/\/+$/, ""); - node.consumerKey = config.consumerKey || ""; - node.consumerSecret = config.consumerSecret || ""; + node.consumerKey = (this.credentials && this.credentials.consumerKey) || config.consumerKey || ""; + node.consumerSecret = (this.credentials && this.credentials.consumerSecret) || config.consumerSecret || ""; node.sendRequest = function (method, path, body, msgHeaders, callback) { const url = new URL(node.baseUrl + path); @@ -48,5 +48,10 @@ module.exports = function (RED) { }; } - RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode); + RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode, { + credentials: { + consumerKey: { type: "text" }, + consumerSecret: { type: "password" } + } + }); };