0

I am new to AngularJS. I know if the response is like { "info" : [{"1"},{"2"}] } then in the promise

.then(function(data)){
   var i= data.info;
} 

The above case I succeeded, but I want to catch the response, if the actual response is like { "info-value" : [{"1"},{"2"}] } the promise will be:

.then(function(data)){
   var i= data.info-value;  // it is saying undefined
} 
halfer
  • 19,824
  • 17
  • 99
  • 186
Naresh k
  • 121
  • 1
  • 2
  • 7

2 Answers2

0

Format of your response is invalid object.

{ "info" : [{"1"},{"2"}] }

It should be like this -

{ "info" : ["1","2"] }

You cannot define object with only key.

Siddharth
  • 6,966
  • 2
  • 19
  • 34
0

Problem is with your response object ,If you are providing keys with object you should have to define them otherwise it would be an invalid object

like this:-

{ "info" : [{"1":''},{"2":''}] }

Shubham Nigam
  • 3,844
  • 19
  • 32