all files / express-stormpath/lib/okta/ request-executor.js

72.73% Statements 8/11
41.67% Branches 5/12
100% Functions 2/2
72.73% Lines 8/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25      12×   12×       12×       12×       12×        
'use strict';
 
var request = require('request');
 
function doRequest(requestShape, callback) {
  request(requestShape, function (err, res, body) {
 
    Iif (err) {
      return callback(err);
    }
 
    Iif (body && body.error) {
      return callback(new Error(body.error_description || body.error));
    }
 
    Iif (res.statusCode > 399) {
      return callback(new Error(body || res.statusCode));
    }
 
    callback(null, body);
 
  });
}
 
module.exports = doRequest;