apiService.js 763 B

123456789101112131415161718192021222324252627
  1. var apiService = angular.module('apiService', []);
  2. apiService.factory('API', ['$location', 'Runs', 'Results', function($location, Runs, Results) {
  3. return {
  4. launchTest: function(url) {
  5. Runs.save({
  6. url: url,
  7. waitForResponse: false,
  8. screenshot: true,
  9. jsTimeline: true
  10. }, function(data) {
  11. $location.path('/queue/' + data.runId);
  12. }, function(response) {
  13. if (response.status === 429) {
  14. alert('Too many requests, you reached the max number of requests allowed in 24h');
  15. } else {
  16. alert('An error occured...');
  17. }
  18. });
  19. }
  20. };
  21. }]);