TypeError: data.forEach is not a function at Store.fetchListSuccess
See original GitHub issueI try fetchList from wordpress API custom navigation, but vuex crud return this error:
TypeError: data.forEach is not a function at Store.fetchListSuccess
What am I doing wrong? My JSON structure look like this:
[ { "id": 2959, "name": "1_Websites", "slug": "1_websites", "description": "", "count": 4, "items": [ { "id": 46783, "order": 1, "parent": 0, "title": "Blog", "url": "https://google.com", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46783, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "blog" }, { "id": 46779, "order": 2, "parent": 0, "title": "Kontakt", "url": "https://google.com/", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46779, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "kontakt" }, { "id": 46781, "order": 3, "parent": 0, "title": "Home", "url": "https://google.com/", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46781, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "home" }, { "id": 46782, "order": 4, "parent": 0, "title": "Ideas", "url": "https://google.com", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46782, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "ideas" } ], "meta": { "links": { "collection": "https://google.com/", "self": "https://google.com" } } }, { "id": 2957, "name": "2_Office", "slug": "2_office", "description": "", "count": 4, "items": [ { "id": 46771, "order": 1, "parent": 0, "title": "Word", "url": "https://office.live.com/start/Word.aspx", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46771, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "word" }, { "id": 46772, "order": 2, "parent": 0, "title": "Excel", "url": "https://office.live.com/start/Excel.aspx", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46772, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "excel" }, { "id": 46773, "order": 3, "parent": 0, "title": "PowerPoint", "url": "https://office.live.com/start/PowerPoint.aspx", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46773, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "powerpoint" }, { "id": 46774, "order": 4, "parent": 0, "title": "OneNote", "url": "https://www.onenote.com/notebooks", "attr": "", "target": "", "classes": "", "xfn": "", "description": "", "object_id": 46774, "object": "custom", "type": "custom", "type_label": "Custom Link", "object_slug": "onenote" } ], "meta": { "links": { "collection": "https://google.com", "self": "https://google.com" } } } ]
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
Hey, glad to you have found it out 🎉. You can use
parseList
option in your crud module to transfer your response to array:I found where was a problem. It was a problem not with vuex-crud but with Wordpress Rest API. JSON was Object with Objects but should be Array of Objects. Second thing is that Wordpress always return id key name like “ID” not “id”. Thank you for your help!