I'm having problems with using functions with YouTube API. it's saying that one of the variables is not defined and I'm not sure what's causing the error. Please help.
http://jsfiddle.net/neowot/p5y4t9co/1/
JS
function QueryGetta0() {
var TTsearchQuery = 'lana del rey';
return TTsearchQuery;
}
function QueryGetta1() {
$.get(
"https://www.googleapis.com/youtube/v3/search",{
part: 'snippet',
maxResults: 1,
q: QueryGetta0(),
type: 'video',
key: 'AIzaSyCvk3NNMQASZgFkCNxIp9jH-l8O0PXhDUo'},
function(data) {
$.each(data.items, function(i, item){
console.log(item);
TTsearchResultID = item.id.videoId;
console.log(TTsearchResultID);
})
}
);
return TTsearchResultID;
}
$('#clicker').on('click', function() {
alert(QueryGetta1());
});