AngularJs $resource use of isArray for both request and response
Not sure if this is a stupid question or not, maybe I'm missing something. When customizing methods on $resource I can use isArray to specify if the resource is an array or not. The problem is that isArray is used, for example with POST, to check both the shape of the request body and of the response. This means that I cannot have, for example, a POST where I need an array of anything (i.e. a set of operations to add to a batch task) in my request and I send a single object as a response (the batch task itself).
This is not a coding problem, I can work around this, it's more a design question: why do response and request have to have the same shape? I do not think that's stated anywhere around how to build REST services, they might usually have the same shape but they do not have to. What am I missing?
Same here. I find this behavior somewhat confusing, especially since the documentation does not mention it.
And it does not look interesting enough... :)
Perhaps it's not so much a question of design, but oversight. Or perhaps it was felt that it would simplify the API for common uses.
Regardless, if you see it as a legitimate design flaw, and have suggestions about how to work around it without hurting anyones applications, and without causing the module to expand in size drastically, it might be something that can be looked at.
Any ideas?
I have no particular idea, it's been a while since I found the "issue" and I had to work around it anyway, I don't have any urge to change it and honestly I don't have the time (and hardly the skills) to propose a sensible alternate approach.
I would just say that it would be nice to have this logic more clearly described in the docs, with maybe some background about why it's like that in case it's been a conscious decision.
This is probably referring to old code that has since changed, because I don't see isArray being used for anything else other than the response. Closing as fixed. Feel free to open a new issue with more details in case Ihave missed your point.