Dealing with Angular 1.6 Error when Using JSONP despite Receiving a 200 Ok Response from URL
I encountered an issue where I need to fetch some data from a JSONP endpoint, and although the response seems to contain the expected data, Angular is still throwing an error.
var url = "https://careers.icims.com/jobs-api/"
var trustedUrl = $sce.trustAsResourceUrl(url);
$http.jsonp(trustedUrl, {jsonpCallbackParam: 'jobs'}).then(function(res){
console.log(res); // unfortunately, this line never gets executed
});
The error message that I am seeing is:
Uncaught ReferenceError: jobs is not defined
at jobs-api?jobs=angular.callbacks._0:1
where jobs
refers to my JSONP callback prefix.
However, if we inspect the response closely, we can see that it includes the JSONP script: https://i.sstatic.net/pR1ci.jpg
Can anyone shed light on why this exception is happening and suggest a solution to overcome it? My current Angular version is 1.6.0.