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.

    Need help for rewrite node_helper.js from 'request' to 'got'

    Scheduled Pinned Locked Moved Development
    19 Posts 2 Posters 2.5k 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.
    • htilburgsH Online
      htilburgs @sdetweil
      last edited by

      @sdetweil

      I kept on searching and think I’ve found it.
      I didn’t use JSON.parse(), but simply put it in the result

          this.sendSocketNotification('MPT_RESULT', result.data.timings);
      

      It works, but I hope this is the right way.

      (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @htilburgs
        last edited by

        @htilpburgs I was going to say the result of json() is passed already

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        htilburgsH 1 Reply Last reply Reply Quote 0
        • htilburgsH Online
          htilburgs @sdetweil
          last edited by

          @sdetweil
          As far as I can see this works the correct way.
          Do you agree?

          (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @htilburgs
            last edited by sdetweil

            @htilburgs depends on what you mean by correct.

            it returns the parsed text as an object
            not text.

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            htilburgsH S 2 Replies Last reply Reply Quote 0
            • htilburgsH Online
              htilburgs @sdetweil
              last edited by

              @sdetweil
              That I don’t understand.
              Is this a problem? What would be better?

              (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @htilburgs
                last edited by

                @htilburgs the response.json() function returns a js object already parsed.

                thst is what yiy were going to fo w JSON.parse(). but don’t need to.

                I don’t know if the CONTENT of the object is correct, but it should be for the same request

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                htilburgsH 1 Reply Last reply Reply Quote 0
                • htilburgsH Online
                  htilburgs @sdetweil
                  last edited by

                  @sdetweil
                  In the previous version with ‘request’ I used JSON.parse() and got the same results.
                  The module works, but I didn’t know for sure if I used the correct approach.

                  (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @htilburgs
                    last edited by sdetweil

                    @htilburgs if you push the repo I’ll look at it… you can do it on a separate branch to not disturb the existing

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    htilburgsH 1 Reply Last reply Reply Quote 0
                    • htilburgsH Online
                      htilburgs @sdetweil
                      last edited by

                      @sdetweil published it. Didn’t know how than on Master.

                      (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @htilburgs
                        last edited by

                        @htilburgs ok, I’ll look at it first thing in the morning

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          sdetweil @sdetweil
                          last edited by

                          @htilburgs I made a couple changes to the Js and added comments to the node_helper, but all looks ok …

                          Sam

                          How to add modules

                          learning how to use browser developers window for css changes

                          htilburgsH 1 Reply Last reply Reply Quote 0
                          • htilburgsH Online
                            htilburgs @sdetweil
                            last edited by

                            @sdetweil
                            Hi Sam, thanks in advance. I’m not at home right now and I only have my smartphone. I cannot test, but I’ll try it in a day.

                            I’ll let you know!!

                            (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              sdetweil @htilburgs
                              last edited by

                              @htilburgs no rush at your availability.

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              htilburgsH 1 Reply Last reply Reply Quote 0
                              • htilburgsH Online
                                htilburgs @sdetweil
                                last edited by

                                @sdetweil
                                Sam, you put a comment in node_helper.js.
                                I don’t understand what you mean.

                                // don’t need this anymore with async below

                                (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

                                S 1 Reply Last reply Reply Quote 0
                                • S Offline
                                  sdetweil @htilburgs
                                  last edited by

                                  @htilburgs ignore. I tried async didn’t help

                                  Sam

                                  How to add modules

                                  learning how to use browser developers window for css changes

                                  htilburgsH 1 Reply Last reply Reply Quote 0
                                  • htilburgsH Online
                                    htilburgs @sdetweil
                                    last edited by

                                    @sdetweil
                                    ;-)

                                    (still trying to learn JS, but not afraid to ask and AI is my best friend) ☺

                                    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 / 1
                                    • 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