When a search is sent I get a 401(Unauthorized) error. The error sometimes goes away when I refresh the page a whole bunch of times but it usually gives this error. If I open the error link in a new tab it shows the formatted data( search results) that I'm trying to get.
Here is what my search function looks like
$scope.search = function () {
$http.get('https://www.googleapis.com/youtube/v3/search',{
params: {
key: 'MY_API_KEY_HERE',
type: 'video',
maxResults : '12',
part: 'id, snippet',
fields: 'items/id,items/snippet/title,items/snippet/description,items/snippet/thumbnails/default,items/snippet/channelTitle',
q: this.query
}
})
.success( function (data) {
$scope.search_results = YoutubeService.listResults(data);
$scope.query = "";
})
.error( function (){
$log.info('search error');
$scope.query = "";
});
};