API Can't be used with Angular JS? Huge bug?

Avatar image for poopertropper
poopertropper

8

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By poopertropper

It appears that the API doesn't like or allows anything other then JSON_CALLBACK and so it doesn't seem to work with AngularJS in anyway. More on the issue here.

https://github.com/angular/angular.js/issues/1551

I've tried to access the api with both the lower level $http as well as $resource with no way to bypass the issues.

$http.jsonp( 'http://www.giantbomb.com/api/search/?format=jsonp&resources=game&api_key=2?callback=JSON_CALLBACK', {

params: {

query: 'Legend'

}

}).then( function ( response ) {

$scope.test = response.data;

console.log($scope.test);

});

Results in error from callback as well as

.factory('GiantFactory', function($resource) {

var base = 'http://www.giantbomb.com/api/search/?format=jsonp&resources=game&api_key=2&query=Legend?callback=JSON_CALLBACK';

return $resource(base, {},

{

get: {

method: 'JSONP'

}

}

);

});

Most API's do not behave this way. Has anyone found a work around to this with Angular? Can we get a fix?

Avatar image for expensiveham
expensiveham

394

Forum Posts

7275

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

#2  Edited By expensiveham
Avatar image for joey
joey

1067

Forum Posts

554

Wiki Points

0

Followers

Reviews: -2

User Lists: 0

#3  Edited By joey

I found the solution here

Instead of `?callback=JSON_CALLBACK`, have `&json_callback=[INSERT YOUR CALLBACK NAME]`

Avatar image for poopertropper
poopertropper

8

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

It is possible using AngularJS. Take a look at this project https://github.com/ckatzorke/angular-giantbomb.

I see the wrappers, but these services don't seem to be working. The odd thing is using JSONP with any other API ive come across has been fine using the methods im my example.

@joey said:

I found the solution here

Instead of `?callback=JSON_CALLBACK`, have `&json_callback=[INSERT YOUR CALLBACK NAME]`

Ive seen this as well, but the issue is that it doesn't seem to like my call back. Not sure what they problem is.