Impossible to send lat and lon to darksky node

Hello
I try to use the darksky node
For this, I send msg.location.lat and msg.location.lon in a function node, and I send it with an inject node.
[{"id":"87c62aba.34caa8","type":"inject","z":"42048d2a.145da4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1140,"y":680,"wires":[["e5fecf71.d830d"]]},{"id":"e5fecf71.d830d","type":"function","z":"42048d2a.145da4","name":"","func":"msg.location.lat = \"50.0\"\nmsg.location.lon = \"4.0\"\nreturn msg;","outputs":1,"noerr":0,"x":1270,"y":680,"wires":[["c830f6ce.1e3398","28223e7a.0300c2"]]},{"id":"c830f6ce.1e3398","type":"darksky","z":"42048d2a.145da4","darksky":"","name":"","lon":"","lat":"","date":"","time":"","mode":"node","lang":"en","units":"us","x":1560,"y":520,"wires":[["6adaee8e.3be07","400bd68e.b1d5f8","4b65a4c4.1dadcc","9d8aa341.55a89","74f8cb95.9c1b04","76ae3e4b.cc65c","74bd0aee.633ef4","4abf0809.18bc28","fd928704.85caf8","f0573735.6ede78","e6d55fd6.3afd1","13d4acba.ea3ea3"]]}]
But I get an error from the darksky node :slight_smile:

17/05/2019 à 23:43:36[node: e5fecf71.d830d](http://192.168.1.10:1880/#)function : (error)

"TypeError: Cannot set property 'lat' of undefined"

Can you tell me my error?

You need to define msg.location before defineing it's parts. So you could do
msg.location = '';
first or define location as an object with

msg.location = {"lat"  : 50.0,
                "lon" : 4.0}

Once more, thanks a lot for your knowledge and help.