Tuesday 9 May 2017

Nodejs JSDOM is undefined inside function

I have some code stripped down here:

'use strict';
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
function foo() {
  JSDOM.fromURL('www.example.com').then((dom) => { 
    // parse code here
  }
}
foo();

When I try to run this, it gives the error Cannot read property 'fromURL' of undefined and quits. For some reference, here is the docs for fromURL and here is the overall docs for jsdom. This is really frustrating, please help!



via Wyrme

No comments:

Post a Comment