0

I have my own module (lets call it klinquist) that uses restler for its rest calls. Currently, I'm just extending it:

var rest = require('restler');

klinquist.prototype.rest = rest;

In my node app, I simply call

klinquist.rest.get("http://...").on('complete', function(response){}); 

and it works great.

I'd like my klinquist node module to do some error checking. For instance, I'd like to check if response instanceOf Error... if http status code 401, run code to refresh access token. After access token is refreshed, then emit the complete to my my node app.

Restler has a dozen functions (.get, .post, etc) and I'd like this logic to apply to all of them without "intercepting them explicitly."

What is the best way to accomplish this?

code-jaff
  • 9,230
  • 4
  • 35
  • 56
klinquist
  • 246
  • 1
  • 4
  • 15

0 Answers0