-
Notifications
You must be signed in to change notification settings - Fork 27.4k
transformResponse data is string in IE11 #8590
Comments
I created a plunker that loads a real json array, and could reproduce the issue (serialized in Chrome, string in IE): http://plnkr.co/edit/E7tgLjZkkrCyOxLsncG5?p=preview |
IE doesn't seem to support http://msdn.microsoft.com/en-us/library/ie/hh872882(v=vs.85).aspx We can detect this and parse the string ourselves. |
webkit had a similar issue until about a year ago, iirc. I think this should already be handled by the try/catch no? I would expect this same logic to also work for the IE case |
I think the issue is that it doesn't throw. It just ignores the responseType value and doesn't parse the response . |
Yeah but I don't think |
I am assuming it is passing this if statement in the try catch, correct? Why not simply check for type string, if responseType === 'json'. If string, parse it and override the variable with the parsed value and continue? |
What happens is, if we get a response that is a string, and we decide it looks like a JSON payload, we parse it. Yes, there are cases where this doesn't do what you expect (like, valid JSON payloads such as This isn't perfect, but I'm having a hard time seeing the issue |
Can the OP create a test case? Perhaps that would help? |
Here is a minimal plunker (stripping out ngResource): Angular 1.2: http://plnkr.co/edit/FbI4OmG99dFG5hR3gShy?p=preview I can't reproduce the issue with v1.2 on IE 11 (Win8), IE 10 (Win8) or IE 9 (WinXP). |
Right! So the problem is that if you provide your own You can see it being re-applied in this plunk: http://plnkr.co/edit/IanQvLYqWTmyBFNLRYIj?p=preview I think this is not a valid issue other than perhaps we should clarify what happens to the default transform function if you provide a specific one. |
@petebacondarwin Could create a docs change for this then? And maybe also a hint how to invoke the original transformer like you did in your example? Assigning this to you as well... |
I'm using transformResponse in $resource service. Below is link for plunker.
I'm using httpBackend, and everything is fine. But If use real backend, data comes as string, and only in IE (tested in IE11).
http://plnkr.co/edit/XmSGFyfSgvPsbTIi7wlm?p=preview
The text was updated successfully, but these errors were encountered: