Navigation

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

    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

    async await Probleme

    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      ljmarkus last edited by

      Moin...

      in meiner tools.js habe ich folgendes stehen:

      var iobrokerObjectJSON = new function () {
      
      	this.get = async function (obj) {
      
      		var x = null;
      
      		await fetch(ioBrokerURL_simpleAPI+'getPlainValue/'+obj).then (function(response) {
      			return response.json();
      		}).then (function(data) {
      			x = data;
      		}).catch (function() {
      			console.log("Error -> iobrokerObectJSON.get");
      		});
      
      		return JSON.parse(x);
      	};
      }
      

      in meiner HTML:

                  var data = '';
      
                  loadObj();
                  function loadObj() {
               
                      data = iobrokerObjectJSON.get('0_userdata.0.Räume.Arbeitszimmer.Heizung.Profile');
                      console.log(data);
                  }
      ....
      ....
      

      leider wird nicht auf eine Antwort gewartet.

      Wie muss die Funktion richtig aussehen?

      UncleSam arteck Gargano 3 Replies Last reply Reply Quote 0
      • UncleSam
        UncleSam Developer @ljmarkus last edited by UncleSam

        @ljmarkus said in async await Probleme:

        var response = await fetch(ioBrokerURL_simpleAPI+'getPlainValue/'+obj);
        return JSON.parse(response.json());
        

        Aber: was machst du da genau? Weshalb SimpleAPI?

        Und: schau dir das mal an: https://gist.github.com/AlCalzone/d14b854b69ce5e8a03718336cc650a95

        1 Reply Last reply Reply Quote 0
        • arteck
          arteck Developer Most Active @ljmarkus last edited by

          @ljmarkus said in async await Probleme:

          Wie muss die Funktion richtig aussehen?

          gut und richtig muss die aussehen... entschuldige meine Reaktion aber meine Glaskugel ist gerade im Keller... und mit dem codeschnippsel kann keiner was anfangen..

          also bitte komplett alles oder zumindest so das man die variablen zu der methode zu der klasse nachvollziehen kann

          1 Reply Last reply Reply Quote 0
          • Gargano
            Gargano @ljmarkus last edited by Gargano

            @ljmarkus Sehe ich das richtig, daß Du von einem entfernten Rechner iobroker Objekte abfrägst ?

            axios wäre ein Weg :

            const axios = require('axios');
            axios.get(url)
              .then((response) => {
                console.log(response.data);
              })
            .catch(function (error) {
                        // handle error
                        console.log(error);
             })
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            382
            Online

            31.8k
            Users

            79.9k
            Topics

            1.3m
            Posts

            javascript
            4
            4
            392
            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