jgr3go / node-wheniwork Goto Github PK
View Code? Open in Web Editor NEWnode.js wrapper for WhenIWork APIs
License: MIT License
node.js wrapper for WhenIWork APIs
License: MIT License
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
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?
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>"}'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.