I am using Bloodhound with a remote API, and I need to convert the result obtained from the remote API.
API URL https://www.googleapis.com/books/v1/volumes?q=quilting , which returns an object with the items property, which is a list. I need to return this list to Typeahead and not to the top level object.
The Bloodhound docs say there is a transform function that should do this , but I can't get it to work.
Here is my code:
var books = new Bloodhound({ datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); }, queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: 'https://www.googleapis.com/books/v1/volumes?q=quilting' }, transform: function(response) { console.log('transform', response); return response.items; } }); books.initialize();
And JSFIddle here: http://jsfiddle.net/2Cres/46/
This does not work because I need to pass the list of items to the typeahead user interface, but this does not seem to be happening.
source share