Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

results.map is not a function #28

Open
matthewdolman opened this issue Sep 21, 2018 · 2 comments
Open

results.map is not a function #28

matthewdolman opened this issue Sep 21, 2018 · 2 comments

Comments

@matthewdolman
Copy link

matthewdolman commented Sep 21, 2018

I have been using the 'http' Api.

But when the response comes back from the server I get there error

ERROR TypeError: results.map is not a function

The structure of my returned object is

{
  result: 1,
  items: [
    {
      name: "matthew",
      age: "21"
    },
    {....
    }
  ]
}
@coryschires
Copy link

We encountered this same problem. The problem is that ngx-typeahead expects the api to return an array – not an object (as shown in your snippet above).

To fix this, afaik, you need to transform the API response on your server so that it responds with an array rather than an object.

Feature Idea: It would be cool if ngx-typeahead let us define a callback function where we could transform the raw API response (e.g. from an object into an array) before handing the data to ngx-typeahead. This way, you could manage everything on the client.

Or... If not that, a more descriptive error message would probably be helpful.

@thebpmgroup
Copy link

Any chance you can give an example of what a "good" array would look like? Looking at the code and trying to guess is taking me nowhere fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants