acquia / waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
https://github.com/acquia/waterwheel.js
233 stars 26 forks source link

Unhandled promise rejection #47

Closed pferlito closed 7 years ago

pferlito commented 7 years ago

I'm no Node.js expert but I can't get this to work.

Created the following test.js file and put it in /libraries/waterwheel-js

const Waterwheel = require('./lib/waterwheel.js');

const waterwheel = new Waterwheel({base: 'http://d8-dev.site', credentials: {oauth: 'RsWv76cNKhbHTVZsGraIE88-dxKWWrBoQ34M70GLPzY'}});

waterwheel.populateResources()
  .then(res => {
    console.log(res);
  });

ran node test.js and got this: (node:80914) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error (node:80914) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

mattgrill commented 7 years ago

@pferlito Hi! Thanks for reporting this.

Turns out this is just an unhandled rejection in your promise. As of Node 7.0.0 all unhandled rejections result in a warning, https://github.com/nodejs/node/pull/8217.

You can do something like,

waterwheel.populateResources()
  .then(res => console.log(res))
  .catch(err => console.log(err));

That should capture the error and let you know what's happening without throwing a warning.

pferlito commented 7 years ago

@mattgrill thanks for your response. Turns out it was a configuration problem with my setup. Working smoothly now.