• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

[MMM-FlightsAbove] Problem receiving and seing JSON from node_helper

Scheduled Pinned Locked Moved Development
promiseasyncjson
13 Posts 3 Posters 4.5k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    raywo Module Developer @E3V3A
    last edited by raywo Feb 27, 2018, 8:44 PM Feb 27, 2018, 8:38 PM

    @E3V3A This function works just fine:

    radarPing: function () {
          radar(53.05959, 12.52388, 51.98161, 14.29552)
            .then((flights) => {
              this.sendSocketNotification("NEW_DATA", flights); //self?
              console.log("New radar data: ");
              console.log(flights);
            })
            .catch(function (error) {
              //console.log("ERROR:")
              console.log(error);
            });
        },
    

    It receives data, prints them on the mirror’s log and sends it to the module. The module is receiving the data and logs them to the browser’s console. And your table is populated too.

    E 1 Reply Last reply Feb 27, 2018, 9:43 PM Reply Quote 1
    • E Offline
      E3V3A @yawns
      last edited by Feb 27, 2018, 9:00 PM

      @yawns That’s yet another one! (And it didn’t give any output.) So far I have seen:

      Log.log()
      Log.info()
      console.log()
      console.error()
      

      Then I have seen more general node ones like:
      console.dir()…

      How can we know where they can be used (and where the output goes)?

      "Everything I do (here) is for free – altruism is the way!"
      MMM-FlightsAbove, MMM-Tabulator, MMM-Assistant (co-maintainer)

      R 1 Reply Last reply Feb 27, 2018, 9:12 PM Reply Quote 0
      • R Offline
        raywo Module Developer @E3V3A
        last edited by raywo Feb 27, 2018, 9:13 PM Feb 27, 2018, 9:12 PM

        @E3V3A console.log() is a standard Javascript function it works anywhere. Log.info() and so on are functions from the MagicMirror’s module system. So they will only work in the module file.

        node_helper.js is executed in the server context. Any console output is therefore on the server’s log.

        The module file is executed in the client context (the browser). So console output from the module file is logged in the browser console.

        1 Reply Last reply Reply Quote 3
        • E Offline
          E3V3A @raywo
          last edited by Feb 27, 2018, 9:43 PM

          @raywo OMG!! I missed your post by not updating my open tabs. Now I found it and it bloody hell it works! I got so excited I fell off my chair!

          I have no idea why the eeek I have been trying to over-engineer this thing. I guess I’m simply not familiar enough with the JS/node notations, and constantly get bogged down with beginners conceptual trivialities.

          Thank you! Tomorrow it will be party!

          "Everything I do (here) is for free – altruism is the way!"
          MMM-FlightsAbove, MMM-Tabulator, MMM-Assistant (co-maintainer)

          1 Reply Last reply Reply Quote 1
          • E Offline
            E3V3A
            last edited by Feb 27, 2018, 9:47 PM

            @yawns BTW. The console.log from main module didn’t want to work in my Firefox (Dev Tools), but console.error() do. It could be a browser issue…

            "Everything I do (here) is for free – altruism is the way!"
            MMM-FlightsAbove, MMM-Tabulator, MMM-Assistant (co-maintainer)

            1 Reply Last reply Reply Quote 0
            • E Offline
              E3V3A
              last edited by Feb 28, 2018, 12:43 PM

              The module is now working and alive!! Thank you all for all your patience!!

              "Everything I do (here) is for free – altruism is the way!"
              MMM-FlightsAbove, MMM-Tabulator, MMM-Assistant (co-maintainer)

              1 Reply Last reply Reply Quote 0
              • 1
              • 2
              • 2 / 2
              2 / 2
              • First post
                12/13
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy