-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(copy) $resource throws TypeError when json has both properties & arrays #2255
Conversation
Hi @joelwreed - it looks like there is a lot of interest in this patch. Right now, though your unit test doesn't fail even if you don't add the patch.
|
|
Once you have a failing unit test can you finesse the commit message. See the guidelines above. First line is a bit long and should describe what is being changed not what is the problem. |
Checked the list and I don't see @joelwreed's signed CLA. Joel, if you've signed under a different name or as a company, let us know! |
Can this fix be merged in? |
I don't think this is actually a real bug, but an incorrect configuration of $resource. See my comments on the issue: #1044 (comment) I think we should have a new PR that provides a better error message in $resource when the response doesn't match what is configured. |
When using $resource you must setup your actions carefully based on what the server returns. If the server responds to a request with an array then you must configure the action with `isArray:true` and vice versa. The built-in `get` action defaults to `isArray:false` and the `query` action defaults to `isArray:true`, which is must be changed if the server does not do this. Before the error message was an exception inside angular.copy, which didn't explain what the real problem was. Rather than changing the way that angular.copy works, this change ensures that a better error message is provided to the programmer if they do not set up their resource actions correctly. Closes angular#2255, angular#1044
Please take a look at #3054 as an alternative. |
When using $resource you must setup your actions carefully based on what the server returns. If the server responds to a request with an array then you must configure the action with `isArray:true` and vice versa. The built-in `get` action defaults to `isArray:false` and the `query` action defaults to `isArray:true`, which is must be changed if the server does not do this. Before the error message was an exception inside angular.copy, which didn't explain what the real problem was. Rather than changing the way that angular.copy works, this change ensures that a better error message is provided to the programmer if they do not set up their resource actions correctly. Closes angular#2255, angular#1044
When using $resource you must setup your actions carefully based on what the server returns. If the server responds to a request with an array then you must configure the action with `isArray:true` and vice versa. The built-in `get` action defaults to `isArray:false` and the `query` action defaults to `isArray:true`, which is must be changed if the server does not do this. Before the error message was an exception inside angular.copy, which didn't explain what the real problem was. Rather than changing the way that angular.copy works, this change ensures that a better error message is provided to the programmer if they do not set up their resource actions correctly. Closes angular#2255, angular#1044
When using $resource you must setup your actions carefully based on what the server returns. If the server responds to a request with an array then you must configure the action with `isArray:true` and vice versa. The built-in `get` action defaults to `isArray:false` and the `query` action defaults to `isArray:true`, which is must be changed if the server does not do this. Before the error message was an exception inside angular.copy, which didn't explain what the real problem was. Rather than changing the way that angular.copy works, this change ensures that a better error message is provided to the programmer if they do not set up their resource actions correctly. Closes #2255, #1044
Closes #1044