Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

"TypeError: callback is not a function" in reactjs

I dont know what is reason of this.
response’s body.

"<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">      
        <script src="/charting_library/charting_library.min.js"></script>
        <title>Charting Library React Demo</title>
    </head>
    <body>
        
        <div id="root"></div>
    
    <script type="text/javascript" src="/static/js/bundle.js"></script></body>
</html>
"

expect body
{
ret_code: 0 //success.
}

help me please…thank you.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The status code is 200 ok, but respond is "./node_modules/stream-http/lib/response.js.exports.IncomingMessage.".
How do i have to get correct response?

My code following as

componentDidMount() {
        // Example of use 
        var req = new MT5Request("localhost", 443); 
    
        // Authenticate on the server using the Auth command 
        req.Auth(111, "passwd",  1985, "WebManager",  function (error) { 
            if (error) { 
                console.log(error); 
                return; 
            } 
            
        });
    }


///auth function
MT5Request.prototype.Auth = function (login, password, build, agent, callback) { 
  if (!login || !password || !build || !agent) 
    return; 
  var self = this; 
  self.Get("/api/auth/start?version=" + build + "&agent=" + agent + "&login=" + login + "&type=manager", function (error, res, body) { 
    var answer = self.ParseBodyJSON(error, res, body, callback); 
    if (answer) { 
      var srv_rand_answer = self.ProcessAuth(answer, password); 
      var cli_random_buf = crypto.randomBytes(16); 
      var cli_random_buf_hex = cli_random_buf.toString('hex'); 
      self.Get("/api/auth/answer?srv_rand_answer=" + srv_rand_answer + "&cli_rand=" + cli_random_buf_hex, function (error, res, body) { 
        var answer = self.ParseBodyJSON(error, res, body, callback); 
        if (answer) { 
          if (self.ProcessAuthFinal(answer, password, cli_random_buf)) 
            callback && callback(null); 
          else 
            callback && callback("invalid final auth answer"); 
        } 
      }); 
    } 
  }); 
  return (true); 
}; 

>Solution :

You are simply calling the callback() function line 28:

callback(null, res, body);

But this function doesn’t seem to exist, no function named callback is natively present in javascript (Try to open your browser’s console or a simple node.js terminal and type callback() and you will see it doesn’t exist.

May shall you show us the code ?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading