mobilefish

Untitled

Sep 18th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PricingService code
  2. ------------------
  3.  
  4.  this.getPriceBookList = function () {
  5.         console.log("Enterted into getPriceBookList");
  6.         var dataObj="grant_type=client_credentials";
  7.         console.log("dataObj in getPriceBookList =" + angular.toJson(dataObj));
  8.         var secret=clientKey+":"+clientPass;
  9.         var base64Encoded= btoa(secret);
  10.        
  11.         var authorizationVal="Basic "+base64Encoded;
  12.         console.log("authorizationVal in getPriceBookList = "+authorizationVal);
  13.        
  14.         $http({
  15.             url: tokenAPI,
  16.             method: 'POST',
  17.             data: dataObj,
  18.             withCredentials:true,
  19.             headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" ,"Authorization":authorizationVal}
  20.         }).then(function(response) {
  21.                  
  22.                 console.log("callTokenAPI result == " + JSON.stringify(response));
  23.                 var accessToken=response.data.access_token;
  24.                                
  25.                 console.log("callTokenAPI access token == " + accessToken);
  26.                 authorizationVal="Bearer "+accessToken;
  27.                  
  28.                 return $http({
  29.                                 url: fetchPriceBookUrl,
  30.                                 method: 'GET',
  31.                                 withCredentials:true,
  32.                                 headers: { "Content-Type": "application/json; charset=UTF-8" ,"Authorization":authorizationVal}
  33.                 });
  34.      
  35.       }, function(error) {
  36.           console.log(error);        
  37.       });
  38.  };
Add Comment
Please, Sign In to add comment