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.

    http request

    Scheduled Pinned Locked Moved Development
    53 Posts 7 Posters 49.3k Views 6 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.
    • A Offline
      acdacd2
      last edited by paviro

      no problemo,

      with this config, black screen

      modules: [
      	{
      		module: 'MMM-HTTPRequestDisplay',
      		position: 'bottom_bar',	// This can be any of the regions. Best results in left or right regions.
      		header: 'MMM-HTTPRequestDisplay', // This is optional
      		config: {
      			httpRequestURL: 'http://192.168.1.248:8889/status.xml',
      			// See 'Configuration options' for more information.
      		}
      	},
      
      1 Reply Last reply Reply Quote 0
      • E Offline
        Eunanibus Module Developer
        last edited by

        Make sure that you’re not just copy and pasting blindly into your config file.

        After each

        modules: [
        {
        etc
        },
        

        Note the comma , after the module. That comma should only be there if there are more modules.

        Likewise, if you’re pasting it last, you need to make sure the module before it has one, to let the script know there are more modules after the previous one.

        So the pattern is

        modules: [
        {
           module: ‘firstModule’,
           config: {
           option : ""
           }
        }, <<< COMMA HERE
        
        modules: [
        {
           module: ‘middleModule’,
           config: {
           option : ""
           }
        }, <<< COMMA HERE
        
        modules: [
        {
           module: ‘last module’,
           config: {
           option : ""
           }
        } <<<<< NO COMMA
        

        hope that makes sense. hopefully that’s the problem.

        1 Reply Last reply Reply Quote 0
        • A Offline
          acdacd2
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • A Offline
            acdacd2
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • E Offline
              Eunanibus Module Developer
              last edited by Eunanibus

              Can you Zip up and upload your config file somewhere I can download it and I’ll take a look? Somewhere like pastebin.

              1 Reply Last reply Reply Quote 0
              • KirAsh4K Offline
                KirAsh4 Moderator
                last edited by KirAsh4

                Hey @acdacd2, please use proper Markdown when posting code. It really isn’t that hard to do and it makes it so much easier and pleasant for others to read, and possibly find errors quicker. Specifically you need to use back ticks before and after your code:

                     ```
                     like so. Note that a back tick is not the same as the normal apostrophe, ` versus ' .
                     ```
                

                A Life? Cool! Where can I download one of those from?

                1 Reply Last reply Reply Quote 1
                • E Offline
                  Eunanibus Module Developer
                  last edited by

                  @KirAsh4 can you confirm MM startup with my module with this config file?

                  The module won’t show any results but MM should boot?

                  1 Reply Last reply Reply Quote 0
                  • KirAsh4K Offline
                    KirAsh4 Moderator
                    last edited by

                    The file ‘status.xml’ doesn’t exist on my system, so it gets a 404 returned, however it does load up, and it does work.

                    0_1466804675808_HTTPRequest.png

                    A Life? Cool! Where can I download one of those from?

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      acdacd2
                      last edited by

                      I have the same message with my environment.
                      In a browse it’s ok

                      1 Reply Last reply Reply Quote 0
                      • KirAsh4K Offline
                        KirAsh4 Moderator
                        last edited by

                        Right, I have not tested this on an actual rpi … I’m at the office, so I’m running a serveronly setup. I can do an rpi test later, although I suspect it will still work, as opposed to resulting in a blank screen. It returns the error as expected when it can’t find the file.

                        A Life? Cool! Where can I download one of those from?

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          acdacd2
                          last edited by

                          with a browser on the pi, it’s also ok

                          1 Reply Last reply Reply Quote 0
                          • E Offline
                            Eunanibus Module Developer
                            last edited by

                            @KirAsh4 I’ve isolated the issue as a Cross-Domain Access issue. Do you know of any particular way to make XMLHTTPRequests to external domains?

                            I wasn’t aware this would be an issue but apparently anybody who wants to use this and map to an external domain will have this issue unless they have a running PHP server that can store the XML results locally (or if they can access a server, they can add the line Access-Control-Allow-Origin: * to their HTML headers.

                            Any ideas?

                            1 Reply Last reply Reply Quote 0
                            • KirAsh4K Offline
                              KirAsh4 Moderator
                              last edited by

                              XMLHTTPRequest. Look at how the 'currentweather' module does it in the 'updateWeather()' function.

                              A Life? Cool! Where can I download one of those from?

                              1 Reply Last reply Reply Quote 0
                              • E Offline
                                Eunanibus Module Developer
                                last edited by

                                Yeah that’s what I based my original request functionality on. The OpenWeather API response is CORS compatible due to the response header - this is why the example response works well. Outside of this domain though (say on http://www.w3schools.com/xml/cd_catalog.xml (or any other external server). This unfortunately makes problems - I’m still looking for a work-around.

                                1 Reply Last reply Reply Quote 0
                                • KirAsh4K Offline
                                  KirAsh4 Moderator
                                  last edited by

                                  Welcome to Javascript security issues.

                                  A Life? Cool! Where can I download one of those from?

                                  A 1 Reply Last reply Reply Quote 0
                                  • A Offline
                                    acdacd2 @KirAsh4
                                    last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • A Offline
                                      acdacd2
                                      last edited by

                                      This post is deleted!
                                      1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        acdacd2
                                        last edited by

                                        This post is deleted!
                                        1 Reply Last reply Reply Quote 0
                                        • A Offline
                                          acdacd2
                                          last edited by

                                          I’m using that code in php

                                          $xml = simplexml_load_file('XML/status1.xml');
                                          echo "<br>--------------<br>XML parsing <br>--------------<br>";
                                          $result = array();
                                          
                                          foreach($xml->children() as $child){
                                          $result[$child->getName()] = trim($child);
                                          1 Reply Last reply Reply Quote 0
                                          • strawberry 3.141S Offline
                                            strawberry 3.141 Project Sponsor Module Developer
                                            last edited by

                                            have a look in here https://forum.magicmirror.builders/topic/240/soccer-standings i had also problems with cors so i used the request module in my node_helper to fix it

                                            Please create a github issue if you need help, so I can keep track

                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • First post
                                              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