venkatvb
venkatvb

Reputation: 671

Parse JSON to JSONP on the fly without using third parties

I am trying to access the codeforces api and they are providing a JSON(but not JSONP) as I'm making a cross domain request, it should be JSONP.

So, I'm using a third party json2jsonp, and it works.

var cfurl = "http://json2jsonp.com/?url=http://codeforces.com/api/user.info?handles=";
var runUserRequest = function(handle){
    return $http({
        method: 'JSONP',
        url: cfurl + handle + "&callback=cfhandle"
    })
}

Finally, my doubt is is there some elegant way to do this without using the third parties like json2jsonp

Thanks in advance

Upvotes: 1

Views: 285

Answers (1)

Paul Sweatte
Paul Sweatte

Reputation: 24617

is there some elegant way to do this without using the third parties like json2jsonp

Use one of the following options:

  • A reverse proxy server
  • A greasemonkey script
  • Browser settings

References

Upvotes: 1

Related Questions