Im trying to write a function that will return data from a locally hosted api so that I can get updated data by calling that function whilst using the var baseUrl = 'http://localhost:3000';
this is my get request:
var baseUrl = 'http://localhost:3000';
function getData(){
    $.ajax({
        type: "GET",
        url: baseUrl + "/jobs", 
        data: "{}",
        success: function(data){
            console.log(data);   
            return data;
        },
        dataType: 'json'
    });
}
Here is an example of setting the response of the request to a variable in a different file:
var myVariable = getData();
when I try to print myVariable it comes back as undefined. Is there a way I can get the returned json object so that I can use it in my program?
 
    