1

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?

Wasp
  • 3,395
  • 19
  • 37
  • I'm facing exactly the same "dilemma": I'm calling a REST service that receives an array using POST, so I have to set the `isArray` property to `true` in my `$resource.save()` function, but the service doesn't return back an array but a single object, so I'm receiving this error from AngularJs: [$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object It's not a blocking error, since the POST call is effective and the object is actually modified in the server, but it's an annoying error to have logged in the console, and I think your point is v –  Oct 16 '13 at 14:46
  • Yeah, to me it would make sense to separate the two. I don't see much action here on SO about this issue, maybe I'll open it on Github :) – Wasp Oct 17 '13 at 07:19

0 Answers0