Q: Bloodhound.js: transform the data returned by a remote source does not work I am using Bloodhound with a remote API and I need to transform the result returned from the remote API.
I am using the https://photon.komoot.io/ API which returns an object with the features property which is an array. I need to transform that array to get only the properties I'm interested in. I am using the transform function but I am not getting the code to work.
$(document).ready(function () {
            // Constructing the suggestion engine
            var suggestions = new Bloodhound({
                    datumTokenizer: Bloodhound.tokenizers.whitespace,
                    queryTokenizer: Bloodhound.tokenizers.whitespace,
                    remote: {
                            wildcard: '%QUERY',
                            url: 'https://photon.komoot.io/api/?q=%QUERY&limit=5',
                            transform: (res)=>{
                                    let places = []
                                    for (const place of res.features) {
                                            const {name ,state ,country} = place.properties
                                            if (name && state && country) {
                                                    places.push(`${name}-${state}-${country}`)
                                            } else if (name && country) {
                                                    places.push(`${name}-${country}`)
                                            } else if (state && country) {
                                                    places.push(`${state}-${country}`)
                                            } else if (name && state) {
                                                    places.push(`${name}-${state}`)
                                            }
                                    }
                                    return places
                            }
                    }
            });
            suggestions.initialize();
            // Initializing the typeahead
            $('#typeahead').typeahead({
                    hint: true,
                    highlight: true, /* Enable substring highlighting */
                    minLength: 1 /* Specify minimum characters required for showing suggestions */
            },
            {
                    name: 'places',
                    source: suggestions
            });
    });

