Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. axios.get Abfrage

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    axios.get Abfrage

    This topic has been deleted. Only users with topic management privileges can see it.
    • haus-automatisierung
      haus-automatisierung Developer Most Active @Cassilo last edited by

      @cassilo Warum nicht einfach mit httpGet?

      C 1 Reply Last reply Reply Quote 0
      • C
        Cassilo @haus-automatisierung last edited by

        @haus-automatisierung
        kann ich auch probieren. Mit axios hats bisher nicht geklappt.
        Muss ich mir mal anschauen http get.

        1 Reply Last reply Reply Quote 0
        • C
          Cassilo last edited by

          Leider funktioniert es mit http get auch nicht.
          Ohne username und password in der url bekomme ich 401 unauthorized.
          Mit in der url bekomme ich einen timeout.
          Für mich heißt das im Prinzip das die Authentifizierung funktioniert aber ich halt an die Daten nicht komme. 😞
          Gruß Jochen

          haus-automatisierung 1 Reply Last reply Reply Quote 0
          • haus-automatisierung
            haus-automatisierung Developer Most Active @Cassilo last edited by

            @cassilo Welche Adapter-Version nutzt Du?

            C 1 Reply Last reply Reply Quote 0
            • C
              Cassilo @haus-automatisierung last edited by

              @haus-automatisierung
              Javascript Adapter in der Version 8.3.1

              haus-automatisierung 1 Reply Last reply Reply Quote 0
              • haus-automatisierung
                haus-automatisierung Developer Most Active @Cassilo last edited by

                @cassilo Dann sollte das so klappen. Oben im Beispiel stimmen übrigens deine Logausgaben in der Reihenfolge später nicht. "Fertig gelesen" wird definitiv vor der Antwort vom Server ausgegeben. Das ist ja alles asynchron.

                https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httpget

                httpGet(
                    'http://192.168.178.113/api/v1/info',
                    {
                        timeout: 2000,
                        basicAuth: {
                            user: 'xx',
                            password: 'xxx',
                        },
                    },
                    (err, response) => {
                        if (!err) {
                            if (response.statusCode === 200) {
                                console.log(`Gelesen: ${response.data}`);
                            } else {
                                console.log(`StatusCode: ${response.statusCode}`);
                            }
                        } else {
                            console.error(err);
                        }
                    }
                );
                
                C 1 Reply Last reply Reply Quote 0
                • C
                  Cassilo @haus-automatisierung last edited by Cassilo

                  @haus-automatisierung

                  danke für die Hilfe. Aber leider ist das Ergebnis das selbe.

                  Mit basicAuth bekomme ich einen Timeout und wenn ich die Zeilen auskommentiere bekomme ich eine 401 Meldung.
                  Ich weiß nicht was, aber irgendwas ist da sehr komisch. Egal welche Methode, das Ergebnis ist leider immer das gleiche.

                  OliverIO 1 Reply Last reply Reply Quote 0
                  • C
                    Cassilo last edited by

                    Was mir aufgefallen ist, ist das der JavasScript Adapter hier folgende Meldung aus gibt.

                    Bildschirmfoto 2024-06-16 um 10.23.47.png

                    haus-automatisierung 1 Reply Last reply Reply Quote 0
                    • haus-automatisierung
                      haus-automatisierung Developer Most Active @Cassilo last edited by

                      @cassilo sagte in axios.get Abfrage:

                      Was mir aufgefallen ist, ist das der JavasScript Adapter hier folgende Meldung aus gibt.

                      Ist schon behoben in der aktuellen Beta.

                      1 Reply Last reply Reply Quote 0
                      • OliverIO
                        OliverIO @Cassilo last edited by

                        @cassilo
                        Hier nochmal ein Hinweis von axios
                        Was die Lösung dazu ist hab ich jetzt direkt nicht gesehen
                        https://github.com/axios/axios/issues/5753

                        nizar787 created this issue in axios/axios

                        closed New version of axios does not allow for encoding user:password in request URL #5753

                        haus-automatisierung 1 Reply Last reply Reply Quote 0
                        • haus-automatisierung
                          haus-automatisierung Developer Most Active @OliverIO last edited by

                          @oliverio Die httpGet-Funktion nimmt intern die URL auseinander und setzt die Header richtig. Funktioniert also auch mit Credentials in der URL.

                          https://github.com/ioBroker/ioBroker.javascript/blob/6162239596a4d4f5ca9001dc136aacf3061f4013/lib/tools.js#L150-L162

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          809
                          Online

                          31.8k
                          Users

                          80.0k
                          Topics

                          1.3m
                          Posts

                          4
                          15
                          563
                          Loading More Posts
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes
                          Reply
                          • Reply as topic
                          Log in to reply
                          Community
                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                          The ioBroker Community 2014-2023
                          logo