Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Unhandled promise rejection #47

Closed
pferlito opened this issue Oct 29, 2016 · 2 comments
Closed

Unhandled promise rejection #47

pferlito opened this issue Oct 29, 2016 · 2 comments

Comments

@pferlito
Copy link

pferlito commented Oct 29, 2016

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

  • Installed Simple Outh module, obtained token
  • Installed Waterwheel drupal module
  • Verified token is working by querying /entity/types/user?_format=json which returns 200
  • Cloned this repo into /libraries/waterwheel-js
  • npm i
  • npm t (all tests passed)
  • Skipped npm run build (trying this in node 7.0.0)

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
Copy link

@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, nodejs/node#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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants