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

};

4
  • 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. Commented Jun 3, 2015 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. Commented Jun 3, 2015 at 18:11
  • What version of angular are you using? Commented Jun 3, 2015 at 18:21
  • get inspiration from stackoverflow.com/a/25783421/2274530 Commented Jun 3, 2015 at 21:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.