HISE Logo Forum
    • Categories
    • Register
    • Login

    Reading external API response

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 213 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JulissaDantes
      last edited by

      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"

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

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

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

        56

        Online

        1.7k

        Users

        11.7k

        Topics

        101.7k

        Posts