Advertisement
paulon

Untitled

Jan 13th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.post(
  2.       '/api/xero/get/taxrates',
  3.       auth.user(),
  4.       function(req, res){
  5.          console.log('get taxrates has been triggered...');
  6.  
  7.          async.series([
  8.             function(next){
  9.                xero.getBillTaxRates({
  10.                   prefix: config.redis.prefix,            
  11.                   user_id: req.user.id,
  12.                   api_id: 'xero'
  13.                },function(err, data){  
  14.                   if(data[0].Status !=='OK'){
  15.                      var failed_data = {
  16.                         result:'failed',
  17.                         message:'Someting went wrong fetching taxrates from api',
  18.                         error: err
  19.                      };
  20.                      next(true,failed_data);
  21.                   }else{        
  22.                      next(null,data[0].TaxRates);
  23.                   }                  
  24.                });              
  25.             }
  26.          ],function(err, result){
  27.             console.log('finish... making a response now...');
  28.             console.log(result[0]);
  29.             response.json(res, result[0]);
  30.          });
  31.       }
  32.    );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement