[Solved] JSONP response with angular http

0

We tried to call the rest api with JSON as well as JSONP method but every time we tried to get the response with JSON method we get Accept header error and then we tired JSONP method which again gives ‘Unexpected  Token : ‘ error while parsing the response. Please point us to the direction where we are doing it wrong. Thank you.

Here is our controller code of angular 

$http({
url : ‘https://restapi.surveygizmo.com/v4/survey/1529356/surveystatistic?user:pass=chris@xxxx.com:xxxxxxx&callback=JSON_CALLBACK’,
method: ‘JSONP’,
}).success(function(data, status) {
console.log(data);
}).error(function(data, status) {

});

And here is our response

Uncaught SyntaxError: Unexpected token :

Richard Goodchild264162 asked

    Best answer

    1

    Hi Richard, 

    For the API to return json or jsonp, specify the return format as follows…

    JSON:

    https://restapi.surveygizmo.com/v4/survey/1529356/surveystatistic.json?user:pass…

    JSONP:

    https://restapi.surveygizmo.com/v4/survey/1529356/surveystatistic.jsonp?user:pass…

    joshwa answered
      • other return options include…
        .xml
        .debug

      • MIND = BLOWN. This should be added to the API docs.
        (for completeness, you can specify the callback function name by adding a “callback” parameter)
        Though, if you were to use this client-side (which is the point of JSONP), your credentials (whether plaintext or md5) are still out there in the open… so in the end this is still pointless, no?

      ×

      Login

      Question stats

      • Active
      • Views6888 times
      • Answers1 answer
      • Followers0 followers