AngularJS $ http错误没有更多请求

时间:2016-03-23 17:21:09

标签: angularjs api jenkins

我正在尝试将我的角度前端与Jenkins API连接。

我的service.js

angular.module('jenkinsLightApp')
.factory('JenkinsService', function (CONFIG, $location, $http, $httpBackend)        {
    return {
        getJobs: function () {
            var viewParameter = 'All';
            if ($location.search().view) {

                // Set the value of the view query parameter
                viewParameter = $location.search().view;
            }
            // Call Jenkins API
            var promise = $http({method: 'GET', url: 'http://xx.xx.xxx.xxx:xxxx/pic/view/All/api/json'}).
                then(function successCallback(response) {
                    alert('promise');
                    // Initialize jobs data
                    var data = response.data;
                    var jobs = [];
                 }, function errorCallback(response) {
                // called asynchronously if an error occurs
                // or server returns response with an error status.
};

我已经从jenkins中删除了身份验证,因此angular可以连接。 但是我有以下错误:

Error: Unexpected request: GET      http://xx.xx.xxx.xxx:xxxx/pic/view/All/api/json
No more request expected
$httpBackend@http://localhost:9000/bower_components/angular-mocks/angular-  mocks.js:1180:1
sendReq@http://localhost:9000/bower_components/angular/angular.js:8442:1 http/serverRequest@(http://localhost:9000/bower_components/angular/angular.js:8162:16qFactory/defer/deferred.promise.then/wrappedCallbackhttp://localhost:9000/bower_components/angular/angular.js:11722:3

我也尝试添加

$httpBackend.whenGET(/pic/).passThrough();

删除了错误,但我仍然无法在浏览器中显示任何jenkins作业。

感谢您的帮助

0 个答案:

没有答案