Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to manage json data from API?

Neil JosephJul 29 2020 — edited Jul 30 2020

I am having trouble managing my data when calling API web services because the result of AJAX result comes in last. To have  a better picture, see code below:

this.variable = ko.observableArray();

this.getAPI = function(){

     $.getJSON("<api_url>", function(result){

          console.log("api result");

          this.variable(result);

     });
console.log("call api");

}

this.setTable = function(){
    this.getAPI();
   console.log(this.variable());
    console.log("set table");
}


CONSOLE:

call api
[ ]
set table
api result


Do you guys have any idea what is the proper way of doing this type of programming setup?

Comments

Processing

Post Details

Added on Jul 29 2020
1 comment
103 views