diff --git a/parsers/what3words/what3words.js b/parsers/what3words/what3words.js index 46e71d47..74062852 100644 --- a/parsers/what3words/what3words.js +++ b/parsers/what3words/what3words.js @@ -44,9 +44,10 @@ module.exports = function(RED) { else if (value.match(w3)) { // see if it's 3 dot separated words node.w3w.wordsToPosition({ words:value }) .then(function(response) { - value.lat = Number(response.split(",")[0]); - value.lon = Number(response.split(",")[1]); - RED.util.setMessageProperty(msg,node.property,value); + var loc = {}; + loc.lat = Number(response.split(",")[0]); + loc.lon = Number(response.split(",")[1]); + RED.util.setMessageProperty(msg,"location",loc); node.send(msg); }) .catch(function(err) { @@ -56,10 +57,10 @@ module.exports = function(RED) { else if (value.match(w1)) { // see if it's a *Oneword node.w3w.wordsToPosition({ words:value }) .then(function(response) { - if (!msg.hasOwnProperty("location")) { value = {}; } - value.lat = Number(response.split(",")[0]); - value.lon = Number(response.split(",")[1]); - value = response; + var loc = {}; + loc.lat = Number(response.split(",")[0]); + loc.lon = Number(response.split(",")[1]); + RED.util.setMessageProperty(msg,"location",loc); node.send(msg); }) .catch(function(err) {