質問

I am trying to fetch data using query action method from a restful service using Angular $resource

When I use the default query method as MyService.query(); I have received the following error:

[$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object

Now, when overload the query action as follows error disappears which is expected.

'query': {method:'GET',IsArray:true}

But the issue is if I set IsArray to false, still there is no error. Why? I should have received the same error as in former case.

What am I missing here please?

役に立ちましたか?

解決

isArray: true is the default for query, and that's also what the error message says.

Note that in your code you write it with a capital I: IsArray.

So it's ignored by angular and your code is equivalent to 'query': {method:'GET'} which in turn is equivalent to 'query': {method:'GET', isArray:false}. That's why you don't get an error in both cases.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top