Thursday, 15 September 2011

angularjs - Why does $http check to see if response data is string -



angularjs - Why does $http check to see if response data is string -

the default transformation of info in angular's $http service check if string, , if not homecoming whatever is. makes unit testing easier because can mock homecoming pojos instead of json strings.

is there non testing case behaviour?

transformresponse: [function(data) { if (isstring(data)) { // strip json vulnerability protection prefix info = data.replace(protection_prefix, ''); if (json_start.test(data) && json_end.test(data)) info = fromjson(data); } homecoming data; }]

the type of data argument depends on responsetype of xhr.

in cases (and default) string, (as more , more browsers back upwards xhr level 2 spec (*cough* ie10 , above *cough*)) can arraybuffer, blob, document or javascript object.

angularjs

No comments:

Post a Comment