How do I store data from an ajax call?

It looks like you are trying to return the data from your ajax call to the function which will not happen due to the asynchronous nature of the ajax call. I am gueesing that this function is inside of your button click handler. so instead, drop the var streams; declaration and do this…

//button click handler
$("#myButton").on('click', function() {
apiCall(function(streams) {
//do things with the stream object
}
});
//ajax call function
function apiCall(callback) {
//contents of your ajax call goes here
//and instead of the streams = data; line in your success function do callback(data);
}

hope this helps