Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    What is right way to do http request on my custom module?

    Troubleshooting
    2
    5
    1771
    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.
    • H
      henrikra last edited by

      At the moment I am calling my external endpoint with XMLHttpRequest in my custom module. But the server has CORS setting on. My current workaround for that is that I am adding webSecurity: false inside electronOptionsDefaults in js/electron.js file. This allows me to do requests to the server without CORS problem.

      My question is there a correct way to do http requests in custom modules? Are there any disadvantages in my current solution?

      Sean 1 Reply Last reply Reply Quote 0
      • Sean
        Sean Module Developer @henrikra last edited by

        @henrikra
        If you have a plan to release that module publicly, you should provide instruction how people to do that solution.

        Usually, do your job in node_helper.js and send data to module with sendSocketNotification(). Your module can get the data with socketNotificationReceived(). It is a more kindly way to other people.

        H 1 Reply Last reply Reply Quote 0
        • H
          henrikra @Sean last edited by

          @Sean Nice! Can you show example project where you have done it like this?

          Sean 1 Reply Last reply Reply Quote 0
          • Sean
            Sean Module Developer @henrikra last edited by

            @henrikra
            Default news feed module doesn’t use xmlHttpRequest, but you can get an idea how to comunicate between module and node_helper.

            1 Reply Last reply Reply Quote 0
            • H
              henrikra last edited by

              Thank you so much! You have guided me to right direction and now I am doing requests the right way in node_helper 🙂

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy