AngularJS defaultHttpResponseTransformtries to find out if the json data is and tries to parse it:
function defaultHttpResponseTransform(data, headers) {
if (isString(data)) {
var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();
if (tempData) {
var contentType = headers('Content-Type');
if ((contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) || isJsonLike(tempData)) {
data = fromJson(tempData);
}
}
}
return data;
}
However, the data in the answer is in text/plain, i.e. swift, and look like JSON, but itβs not. And when Angular tries JSON.parse, I get an error:
SyntaxError: Unexpected number in Object.parse (native) at fromJson ( http: // localhost: 8080 / WebEastGui / build / js / app-vendor.js: 41198: 14 )
Is there a way to get Angular not to force JSON parsing as a string?
source
share