mobilefish

Untitled

Sep 18th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this.callAPI = function () {
  2.            
  3.         var dataObj="grant_type=client_credentials";
  4.         console.log("dataObj in pricingservice =" + angular.toJson(dataObj));
  5.         var secret=clientKey+":"+clientPass;
  6.         var base64Encoded= btoa(secret);
  7.        
  8.         var authorizationVal="Basic "+base64Encoded;
  9.         console.log("authorizationVal in pricingservice = "+authorizationVal);
  10.        
  11.         return $http({
  12.             url: tokenAPI,
  13.             method: 'POST',
  14.             data: dataObj,
  15.             withCredentials:true,
  16.             headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" ,"Authorization":authorizationVal}
  17.         })
  18.                
  19.    
  20.            // ONCE THE RESPONSE  IS RECEIVED FROM ABOVE HTTP CALL , I WANT TO initiate  NEXT HTTP CALL
  21.    
  22.                 $http({
  23.                 url: anotherUrl,
  24.                 method: 'GET',
  25.                 withCredentials:true,
  26.                 headers: { "Content-Type": "application/json;charset=utf-8" ,"Authorization":authorizationVal }
  27.                })
  28.    
  29.    
  30.    
  31.     };
Add Comment
Please, Sign In to add comment