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.

content.ForEach is not a function

See original GitHub issue

Hello, I am a developer of a Homebridge plugin, and I am having a user report this error:

[12/23/2020, 4:09:41 PM] TypeError: content.forEach is not a function
    at parse (/homebridge/node_modules/homebridge-adt-pulse/node_modules/cheerio/lib/parse.js:38:15)
    at Function.exports.load (/homebridge/node_modules/homebridge-adt-pulse/node_modules/cheerio/lib/static.js:39:14)
    at /homebridge/node_modules/homebridge-adt-pulse/api.js:598:39
    at arrayMap (/homebridge/node_modules/homebridge-adt-pulse/node_modules/lodash/lodash.js:639:23)
    at Function.map (/homebridge/node_modules/homebridge-adt-pulse/node_modules/lodash/lodash.js:9580:14)
    at Request._callback (/homebridge/node_modules/homebridge-adt-pulse/api.js:597:28)
    at Request.self.callback (/homebridge/node_modules/homebridge-adt-pulse/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (/homebridge/node_modules/homebridge-adt-pulse/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:315:20)
[12/23/2020, 4:09:41 PM] Got SIGTERM, shutting down Homebridge...

More details in this issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
5saviahvcommented, Dec 24, 2020

sample from your code where it happens

...
const $ = cheerio.load(body);
const sensors = $('#orbSensorsList table tr.p_listRow').toArray();

const output = _.map(sensors, (sensor) => {
  const theSensor = cheerio.load(sensor);
  const theName = theSensor('a.p_deviceNameText').html();
  ...
})
...

variable sensor is single object (html node)

older version wraps it into array

1reaction
MegEdnazednavcommented, Mar 9, 2021

Hello, we are recently encountering this issue in our application as well, coming from a dependency that we are using. Could you tell us when the new version with the fix will be released? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
TypeError: foreach is not a function in JavaScript - Java2Blog
TypeError : .foreach is not a function occurs when we call foreach() function on object which is not array , Set or Map...
Read more >
Solving: forEach is not a function - Beamtic
The best solution is to make sure you got the correct data type to begin with; in order for the forEach method to...
Read more >
TypeError: forEach is not a function in JavaScript - Stack Diary
The "TypeError: forEach is not a function" error is thrown when the code attempts to call the forEach() method on a value that...
Read more >
How to to solve 'TypeError: forEach is not a function' error in ...
The reason why the error happens is that you are trying to call .forEach function on something which is not an array, Map...
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