Convert HP Api calls to angular.js