JSONP $http request to Dreamfactory returns server error

207 Views Asked by At

I am trying to access the dreamfactory data through $http request. To handle cross domain request, i have just added the JSON callback with the url.

.factory('DonorService', ['$resource','$http', '$q',
    function($resource,$http,$q){
    return{
        getDonors:function(){
            var donor = "https://dsp-sixerofsixes.cloud.dreamfactory.com/rest/db/icbd_donors/?callback=JSON_CALLBACK&app_name=blooddonate&fields=*";
            var deferred = $q.defer();
            $http.jsonp(donor).
            success(function(data, status, headers, config) {
                console.log(data);
                deferred.resolve(data);
            }).
            error(function(data, status, headers, config) {
                console.log(data);
            });
            return deferred.promise;
        }
    }
}])

But on making the request it creates a internal server error in the df. while typing the url in the browser shows the data along with wrapping callback.

Link to the JSON data

Link which is actually called from JSONP

1

There are 1 best solutions below

0
On

I can't comment yet, so I guess I'll have to write this here.

Remove the resource injection. Just use $http.

ngResource incrementally creates those angular callback names.