Skip to content

Error: undefined is not iterable (cannot read property Symbol(Symbol.iterator)) #1775

Answered by pdehaan
danielLee0721 asked this question in Q&A
Discussion options

You must be logged in to vote

Off the top of my head, I wonder if it's possibly just a typo (sortByAlph vs soryByAlph in your code above):

{%- assign indexList = collections['type'] | sortByAlph -%}

versus

// Should this be "sortByAlph"?
eleventyConfig.addFilter("soryByAlph"

Or, possibly the "undefined is not iterable" is referring to the collections['type'] returning undefined (unneeded single quotes around that type variable) causing the result to be undefined and then trying to call .sort() on an undefined object...

{%- assign indexList = collections['type'] | sortByAlph -%}

You might need an additional check to see if vals is an array before trying to call .sort(). I'd have to test it out locally to see what you …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@danielLee0721
Comment options

@pdehaan
Comment options

pdehaan May 12, 2021
Collaborator

@pdehaan
Comment options

pdehaan May 12, 2021
Collaborator

@danielLee0721
Comment options

Answer selected by danielLee0721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants