• 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.

Long running tasks - json parsing from url

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 1.4k Views 2 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.
  • C Offline
    chef
    last edited by Mar 11, 2018, 4:29 PM

    Good day,
    I’ve been spending some time reviewing the module development page.
    Reading through the MMM-JSON-Feed module documentation in the 3rd party modules section of the github, I was hoping to get some insight into why parsing json through the module is giving me trouble.

    I have created an endpoint plugin form my emby media server which returns a json object as follows:

    {"MediaNames":["Family Guy","Nashville","Stargate: Origins","Stargate Atlantis","Stargate Universe","Lethal Weapon","Black Lightning","Arrow","Young Sheldon","This Is Us","Legion","Marvel's Agents of S.H.I.E.L.D.","The Flash","Supergirl","Gotham","Agents of S.H.I.E.L.D.","Archer (2009)","The Big Bang Theory","The Walking Dead","Supernatural","Legends of Tomorrow"]}
    

    I believe I have run into problems because the json object returned from my server endpoint may need to parse asynchronously. No matter how many attempts to request info from my url, no json is parsed from the feed module.

    I’ve attempted to rewrite the request portion of the 'helper module", several different ways to parse the json from the url properly, but alas no joy.
    My brain hurts now from reading so much Stackoverflow… lol!
    I have two questions that might help me:

    1. is there a log available for MM, or a way to show the console readout, to help search for errors.

    2. Does the version of Nodejs that the MM is built on allow for async/await operators in functions? If not does anyone have an example of using promises in module development to return a long-running task and have the information return back to the modules primary js file, to display on the mirror?

    Many thanks,

    chef

    E 1 Reply Last reply Mar 11, 2018, 5:54 PM Reply Quote 0
    • E Offline
      E3V3A @chef
      last edited by E3V3A Mar 11, 2018, 5:56 PM Mar 11, 2018, 5:54 PM

      @chef Hi Chef!

      Yes, I recently had the same “issues”. Pretty much everything using/parsing JSON are Promises, almost by default, but listen to this. You can probably ignore most of this, including any async/await stuff. Please look how my Flights module is parsing the promises from the API. If not there, look at the api itself. In addition you might even wanna use the Tabulator thing for your own purpose.

      "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
      • C Offline
        chef
        last edited by Mar 12, 2018, 12:22 AM

        Thank you for the direction. It would seem that after a full day of mucking about, I have finally got it. Horray!
        Emby Media Server now has a place on my mirror.

        I’ll have to go tell the guys over there about. I have a feeling this Magic Mirror might catch on over there, especially now that there will be an official Emby plugin for it.

        Thank you again @E3V3A for taking the time to show some direction.

        Chef

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        1 / 1
        • First post
          1/3
          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