I am doing a REST request for an array of objects using JQuery.
In the "success" part of the code everything is fine - the objects in the array are converted to the right type. However, when I try to assign them to a variable (docStructures) and move the variable out of the JQuery method, the objects become "undefined".
How can I avoid this and pass the variable outside of the method's scope persisting the right type of the objects?
jQuery.ajax({
  type: 'GET',
  url: contextPath + "/rest/dcm-jira/1.0/document/structure",
  data: {
    "issueId": selectedRevision.issueId
  },
  success: function(structures) {
    docStructures = structures;
    console.log(docStructures)
  },
});
console.log(docStructures)
 
     
     
    