我正在尝试 node-red...
我做这个网络查询 https://api.forecast.io/forecast/
这是给定的输出:
{"latitude":-25.74486,"longitude":28.18783,"timezone":"Africa/Johannesburg","offset":2,"currently":
{"time":1462871342,"summary":"Foggy","icon":"fog","precipIntensity":0,"precipProbability":0,
"temperature":18.08,"apparentTemperature":18.08,
"dewPoint":9.3,"humidity":0.57,"windSpeed":3.75,"windBearing":351,"visibility":2.78,
"cloudCover":0.23,"pressure":1024.87,"ozone":252.43}}
这似乎是正确的。
Parse Weather中的代码是
//parse forecast.io message
var weather = JSON.parse(msg.payload);
return weather.currently.temperature;
我得到的错误是:
TypeError: Cannot assign to read only property '_msgid' of 19.49
这个值似乎还可以。
我做错了什么?
提前致谢。
最佳答案
问题出在您的 Parse Weather 函数中。您正在返回一个 int (18.08),Function 节点需要返回一个 msg 对象。
尝试这样的事情:
var weather = JSON.parse(msg.payload);
msg.payload = weather.currently.temperature;
return msg;
关于node-red - 类型错误 : Cannot assign to read only property '_msgid' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37135372/