Reading external API response



  • All this code is on init, why is isDefined(an) == true, shouldn't it have the response json?:

    const var p = {
        "request": "some text"
    };
    
    reg an;
    Server.setBaseURL(url);
    Server.callWithGET("/", p, function(status, response)
    {
         an = response;
         Console.print(trace(response));//This shows the json object on the console with no problems
    });
    if(isDefined(an)){
    Console.print("Something is wrong");
    }
    

    How can I use the response? is "undefined"



  • This call is asynchronous - the function will be executed when you get a server response. The onInit callback will be long over by then.


Log in to reply
 

8
Online

881
Users

3.1k
Topics

26.6k
Posts