Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function retsAPI($http, $q) {
  2. var service = {};
  3.  
  4. service.get = function(values) {
  5. var val = [];
  6. jQuery.each(values, function(key, value) {
  7. val.push(key + '=' + value);
  8. });
  9.  
  10. return $http({
  11. url: 'http://website.net/search.php?' + val.join('&'),
  12. method: 'get',
  13. withCredentials: false,
  14. crossDomain: true,
  15. headers: {
  16. 'Content-Type' : 'application/json',
  17. 'Access-Control-Allow-Headers' : '*'
  18. }
  19. }).then(function (response) {
  20. if(response) {
  21. response.data.forEach(function(item) {
  22. /**
  23. * Update and modify values here if needed.
  24. */
  25. item['L_AskingPrice'] = parseFloat(item['L_AskingPrice']).toFixed(0).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
  26. });
  27.  
  28. return response.data;
  29. } else {
  30. return $q.reject();
  31. }
  32. })
  33. };
  34.  
  35. return service;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement