question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

xmlobj.Contents.forEach is not a function

See original GitHub issue

For some reason distribution version of the package does not wrap all xmlobj.Contents accesses with toArray. I checked source code, and it seems everything is fine there, but for some reason in the node_modules/minio/dist/main/xml-parsers.js first access of the xmlobj.Contents (line 387) is not wrapped with toArray.

I might be missing something obvious here.

How to reproduce

I’m using express-middleware-minio package, and when I try listing all files in the bucket, I get that error. I’m pretty sure, it’s not related to that package.

I’ve tried to create an empty project, install minio with:

$ yarn add minio

and check dist directory of the package:

$ cat -n node_modules/minio/dist/main/xml-parsers.js | grep xmlobj.Contents

Output was:

386	  if (xmlobj.Contents) {
387	    xmlobj.Contents.forEach(function (content) {
436	  if (xmlobj.Contents) {
437	    toArray(xmlobj.Contents).forEach(function (content) {
481	  if (xmlobj.Contents) {
482	    toArray(xmlobj.Contents).forEach(function (content) {

As you can see, first access of the xmlobj.Contents is not wrapped with toArray.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
narrowizardcommented, Aug 20, 2021

it works, thank you very much @prakashsvmx , you saved my day.

Seems the latest version is 7.0.19, but it doesn’t matter. 7.0.19 works very well.

2reactions
zoltan-mihalyicommented, Apr 27, 2021

I think issues should not be closed before the release. The same bug was reported multiple times, because we can’t find the original issue. When I find the original issue, which is closed, I assume my bug report is different, because it still exists in the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - xmlobj.Contents.forEach is not a function -
Contents accesses with toArray . I checked source code, and it seems everything is fine there, but for some reason in the node_modules/minio/dist/main/xml- ......
Read more >
forEach is not a function error with JavaScript array
First option: invoke forEach indirectly. The parent.children is an Array like object. Use the following solution: const parent = this.el.
Read more >
Solved: Re: Can we convert object into XML inside Javascip...
This forEach invokes a function one time for each of the ID's in the array. ... var xmlobj = new XML(response.content); var json ......
Read more >
SimpleXML Functions - Manual - PHP
SimpleXML Functions ¶. Table of Contents ¶ ... foreach ( (array) $xmlObject as $index => $node ) ... will silently NOT output any...
Read more >
TypeError: foreach is not a function in JavaScript - Java2Blog
Table of Contents [hide]. Use Object.keys() or Object.values() or Object.entries(); Use Arrays.from(). TypeError: .foreach is not a function occurs when we ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found