diegoaguilar diegoaguilar - 2 months ago 22
AngularJS Question

How to paginate if no page token present in Youtube API search request

I'm querying videos to Youtube API with AngularJS this way:

$http.get('https://www.googleapis.com/youtube/v3/search', {
params: {
key: 'API_KEY',
type: 'video',
part: 'id,snippet',
maxResults: '10',
fields: 'items/id,items/snippet/title,items/snippet/description,items/snippet/thumbnails/default,items/snippet/channelTitle',
q: query
}
}


However, the response object is only returning a JSON response with
items
property but there's not a
nextPageToken
or
pageInfo
properties.

I need to obtain multiple results, so it's pretty important to me to be capable to paginate the search.

I already tried with out
maxResults
query param but got not results. How can I achieve it?

Answer

I was trimming the API answer to myself:

fields: 'items/id,items/snippet/title,items/snippet/description,items/snippet/thumbnails/default,items/snippet/channelTitle'

So the fields param is the one telling API which response properties to include.