[Node.js] phantom Module's addCookie Method Arguments Changed

Tadashi Shigeoka ·  Tue, March 31, 2015

The arguments for the addCookie method in phantom, a PhantomJS wrapper for Node.js, changed from version 0.7.1 to 0.7.2.

As a result, code using the addCookie method stopped working due to errors.

phantom stdout: TypeError: incompatible type of argument(s) in call to addCookie(); candidates were
    addCookie(QVariantMap)


phantom stdout:   /u/apps/myapp/shared/node_modules/phantom/shim.js:5621
  /u/apps/com/shared/node_modules/phantom/shim.js:4526
  /u/apps/com/shared/node_modules/phantom/shim.js:4502
  /u/apps/com/shared/node_modules/phantom/shim.js:4382
  /u/apps/com/shared/node_modules/phantom/shim.js:4370

The change is:

addCookie: (name, value, domain, cb=->) ->

to

addCookie: (cookie, cb=->) ->

The arguments have simply changed.

So instead of passing name, value, domain as individual arguments, you need to modify the code calling the addCookie method to pass them bundled together as a cookie object.

For details, reading the above issue and pull request will clarify that it was modified to align with PhantomJS API.

That’s all from the Gemba.