Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat($resource): pass isArray to http config #13109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tautvilas
Copy link

This will allow to indentify request type in global interceptor.

I need to identify if request is array or object and put necessary array or object to httpCache accordingly if request does not need to be made.

This will allow to indentify request type in global interceptor.
@gkalpak
Copy link
Member

gkalpak commented Oct 16, 2015

I don't get the usecase (and I suspect this might not be something commonly useful to include in core).
Could you provide more details on why you need this/how you will use this ? (An example maybe ?)

@tautvilas
Copy link
Author

You are right, this is not a common usecase. But, why drop isArray param? I would expect all data that I enter in resource configuration to be found in http config object. I can find cache, method, header and transformer params, so why no isArray?

@gkalpak
Copy link
Member

gkalpak commented Oct 16, 2015

Hm...good point. As a work-around, you can pass your custom param (but you must be in charge of all $resources and it's less than ideal). E.g.:

var Thing = $resource('/api/thing/:id', {id: '@id'}, {
  query: {method: 'GET', isArray: true, itsAnArray: true}
});
// ...then look for `config.itsAnArray` in your interceptor

Regarding the question "why not to include isArray":
I guess it was skipped in the first place, because it is a $resource-specific property and doesn't have any usefulness for $http.
On the other hand, it is (kind of) related to/characterizing the request.

I could definitely leave with passing isArray to $http.
So, it LGTM after all.

Let's see what other people have to say.

@tautvilas
Copy link
Author

Thanks, I will implement temporary workaround and will wait for what you decide

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants