0

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 = "";
});

};

  • Have you tried looking into the network tab of your developer tools? There you should be able to get more information like the data returned. – Nils Jun 03 '15 at 17:46
  • Yes, I took a look at what was actually returned. I don't if you took a look at the "error link" but if I right click on the error and 'open in new tab' it shows the json data I'm trying to get. – iyasu watts Jun 03 '15 at 18:11
  • What version of angular are you using? – jlmcdonald Jun 03 '15 at 18:21
  • get inspiration from http://stackoverflow.com/a/25783421/2274530 – mpgn Jun 03 '15 at 21:40

0 Answers0