Why is so difficult to get a https REST + keep `msg`? (OSM)

Sorry for spamming the topic but after 4 days of struggle I must ask:

  • Am I missing something trivial here?
  • Or is it really NR making hard to get a https GET while keeping the msg details?

The goal: :railway_track:

is to get a simple :satellite: GPS coords from OSM using nominative. (Example)

lat: 47.6678184
lon: 19.0774145

And keep the user informed about the progress. (Using WorldMap + Toast)
... maybe even a timeout countdown, a non-success info, etc.

The way:

  1. First I've thought let's ask ChatGPT --> it gave me 2 simple functions to:

    • an OSM async, which used fetch(url)
    • a toast function

    None of them worked, because Node-RED does not allow to use fetch() from a function


  1. The recommended "http request node" was a total failure:
  • did not work at first, because I've used {{{msg.url}}} instead of {{{url}}}
    (That's not logical. Also why didn't the code auto-delete msg. part?)

  • What about the SSL checkbox? Why getting unchecked if I click DONE ?
    No help about it !

  • Also: msg.url is reserved, gave me a strange "deprecated" error. Had to dig for hours...
    No warning in help about it either!

  • And the final arrow into my back:

    • The result was only the http result, nothing else! :pouring_liquid:
    • So the original msg data is all gone! :dashing_away:
    • No reference left to identify "what was the question? 42 ?" :exclamation_question_mark:

    All reference to the point I was asking the coords for, was deleted by the node.

    WTF ??? :scream:


  1. Than I've found Axios.
  • After installing it from Palette Manager,

  • and using the same way as the "http request node":

    same result, deleted msg.data = no go. :frowning:

  • ChatGPT recommended to call from a function with this code:

const axios = global.get('axios');

async function autoOSM(F_) {

    try {
        let res = await axios.get(F_.url, {
           headers: {
             'Accept':'application/json',
             'User-Agent':'Node-RED'
           }
        });

        let data = res.data;
...
  • but it gives this error:
    Cannot read properties of undefined (reading 'get')

At this point I've decided to open this topic to ask for help :ring_buoy:

The built in help states:

If not configured in the node, this optional property sets the url of the request.

i.e. leave it blank and you can set msg.url before the http request.

As above, if you set msg.url BEFORE the node AND populate the url field, it gives you a warning:

Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props

And that bitly address takes you to Deprecated: Message properties overriding set node properties · node-red/node-red Wiki · GitHub where it tells you exactly what/why

Assuming your value "what was the question? 42 ?" was in msg.payload, then you cannot expect it to be kept when the http request node itself returns its own result in msg.payload.

If you want to retain original msg values put them/move them/copy them to literally anywhere except msg.payload e.g...

@Steve-Mcl Thank your very much the detailed explanation! :heart:

Yes, I did that, before I've opened this topic!

The problem was:

  • the Debug node was not set to show the "whole msg" !

:exploding_head:

I do not know who's idea was setting all debug notes to msg.payload by default, but I keep forgetting to change them one by one.
It is very rare, that a msg is containing only the payload as important data.

Exactly that's my point. Call me an idiot, but (after reading it 5x ! ) maybe:

  • if I could not understand,
  • users with less English knowledge & less NR experience

will understand it even less.

So what if help would contain a simple sentence instead, like:

Leave URL blank, if you send it via msg.url !

And the node would accept both {{{msg.myUrl}}} and {{{myUrl}}} too?
Probably it would take +1 line in the code to make it more user friendly:

if ( mustage_value === undefined && ... === 'msg.' )  ...