Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Error in callback: TypeError: axios is not a function

    NEWS

    • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    Error in callback: TypeError: axios is not a function

    This topic has been deleted. Only users with topic management privileges can see it.
    • cash
      cash Most Active last edited by

      Nach dem Update vom JavaScript Adapter habe ich auf einmal Fehler bei Scripten wo ich axios nutze. Was muss ich ändern damit es wieder läuft?

      Hier ein Teil vom Script welches das Problem ist. Variablen wie z. B. pushover_acknowledged ist weiter oben im Script deklariert.

      
      //Pushover muss bestätigt werden
                  if(pushover_acknowledged){
                      pushover_acknowledged = false;
                      const axios = require('axios');
                      var URL = 'https://api.pushover.net/1/receipts/cancel_by_tag/'+pushover_tag +'.json';         
                                  
                      axios({
                          method: 'post',
                          url: URL,
                          //headers: {'Content-Type':'application/x-www-form-urlencoded'} ,  
                          data: {
                              "token": 'xxxx'
                              },
                          timeout: 4500,
                          responseType: 'json'
                      })
                      .then((response) => {
                          if(debugging){
                              log('data:' +JSON.stringify(response.data));
                              log('Status: ' +response.status);
                              //log('Header:' +response.headers);
                          }
                          if(response.status = 200){
                              //Umwandeln in String
                              var data_string = JSON.stringify(response.data)
                              var data_split_1= data_string.split(",");
                              var data_split_2= data_split_1[1].split(":");
                              var _result = parseInt(data_split_2[1],10);
                              
                              if(_result > 0){
                                  log('Pushnachricht wurde automatisch bestätigt. --- Anzahl bestätigter Nachrichten: '+_result );
                              }
                              else{
                                  log('Pushnachricht konnte nicht bestätigt werden.' +data_string)
                              }
                          }
                          else{
                              if(logging){
                                  log('Es gibt ein Problem: ' +response.status,'warn');
                              }
                          } 
      
                      })
                      .catch(
                          (error) => {
                              // handle error
                              log('Es gibt einen Fehler: ' +error,'warn');           
                          }
                      );
      
      
      Ro75 Asgothian 2 Replies Last reply Reply Quote 0
      • Ro75
        Ro75 @cash last edited by

        @cash ist axios als zusätzliches NPM Paket im JS Adapter eingetragen?

        Ro75.

        cash 1 Reply Last reply Reply Quote 0
        • Asgothian
          Asgothian Developer @cash last edited by Asgothian

          @cash sagte in Error in callback: TypeError: axios is not a function:

          Nach dem Update vom JavaScript Adapter habe ich auf einmal Fehler bei Scripten wo ich axios nutze. Was muss ich ändern damit es wieder läuft?

          Hier ein Teil vom Script welches das Problem ist. Variablen wie z. B. pushover_acknowledged ist weiter oben im Script deklariert.

          
          //Pushover muss bestätigt werden
                      if(pushover_acknowledged){
                          pushover_acknowledged = false;
                          const axios = require('axios');
                          var URL = 'https://api.pushover.net/1/receipts/cancel_by_tag/'+pushover_tag +'.json';         
                                      
                          axios({
                              method: 'post',
          [...snip]
          
          

          Hmm.. nach der Axios doku kann das so eigentlich nicht gelaufen sein. Hast du da am Skript was getan (request gegen Axios getauscht ? )

          Unsinn - ich hab an der falschen Stelle geschaut.

          A.

          1 Reply Last reply Reply Quote 0
          • cash
            cash Most Active @Ro75 last edited by

            @ro75 ja habe ich.

            @Asgothian Das lieft vermutlich seit dem 04.02.21 wenn meine Dokumentation halbwegs stimmt. Letzte Änderung am Script am 22.04.24

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

            Support us

            ioBroker
            Community Adapters
            Donate

            458
            Online

            32.4k
            Users

            81.3k
            Topics

            1.3m
            Posts

            3
            4
            24
            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