Code Monkey home page Code Monkey logo

node-wheniwork's People

Contributors

jgr3go avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

node-wheniwork's Issues

Constructor throws uncatchable exceptions when misconfigured

Explanation:

The constructor calling a function that kicks off an async request, and then that promise rejection throws an exception means the exception is uncatchable. If we must call login in a constructor, then we should expose the promise as a class property, or, ideally, don't call login in the constructor and let that be called later, with the request returning its promise so we can handle it accordingly. This error chain means a misconfigured WiW account, or a bad WiW response can tank a whole process.

Observed behavior:

var WiW = require('wheniwork');
try {
  let foo = new WiW.WIW('','','',{});
}
catch(ex) {
  console.log("oops! ", ex);
}

Unhandled rejection Error: 1110 - Application not found
    at .../node_modules/wheniwork/dist/wheniwork.js:49:19
    at tryCatcher (.../node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (.../node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (.../node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (.../node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (.../node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (.../node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (.../node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (.../node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (.../node_modules/bluebird/js/release/async.js:15:14)

Expected Behavior:

Oops! ... "Application not found", etc, etc

WIW is not a constructor

I'm getting the following error when attempting to use your module:

./getWIWSchedule.js:3
let wiw = new WIW("apikey", "username", "password");
          ^

TypeError: WIW is not a constructor
    at Object.<anonymous> (./getWIWSchedule.js:3:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

This is a copy paste of your basic usage into node. Any help?

Occasional authentication errors

We have been using this for a long time and have an ongoing error that we have not been able to solve, Occasionally we get the below error that appears to be from the token expiring or getting dropped leading to authentication issues.

{ Error: 1000 - User login required for this resource.
     at request.catch.err (/app/node_modules/wheniwork/dist/wheniwork.js:49:19)
     at tryCatcher (/app/node_modules/request-promise/node_modules/bluebird/js/release/util.js:16:23)
     at Promise._settlePromiseFromHandler (/app/node_modules/request-promise/node_modules/bluebird/js/release/promise.js:547:31)
     at Promise._settlePromise (/app/node_modules/request-promise/node_modules/bluebird/js/release/promise.js:604:18)
     at Promise._settlePromise0 (/app/node_modules/request-promise/node_modules/bluebird/js/release/promise.js:649:10)
     at Promise._settlePromises (/app/node_modules/request-promise/node_modules/bluebird/js/release/promise.js:725:18)
     at _drainQueueStep (/app/node_modules/request-promise/node_modules/bluebird/js/release/async.js:93:12)
     at _drainQueue (/app/node_modules/request-promise/node_modules/bluebird/js/release/async.js:86:9)
     at Async._drainQueues (/app/node_modules/request-promise/node_modules/bluebird/js/release/async.js:102:5)
     at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/request-promise/node_modules/bluebird/js/release/async.js:1
     at runCallback (timers.js:705:18)
     at tryOnImmediate (timers.js:676:5)
     at processImmediate (timers.js:658:5)
     at process.topLevelDomainCallback (domain.js:120:23) status: 401, code: 1000 }

Reading the https://apidocs.wheniwork.com/external/index.html and running the curl provides no TTL on the token so i'm not sure whats happening here if the token has a hidden expiry or if its getting dropped somewhere.

curl -X POST \
  https://api.login.wheniwork.com/login \
  -H 'W-Key: <INSERT_DEVELOPER_KEY_HERE>' \
  -H 'content-type: application/json' \
  -d '{"email":"<INSERT_USERNAME_HERE>","password":"<INSERT_PASSWORD_HERE>"}'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.