0

not sure what is wrong with this

const info= getUserInfo('michael').then(response => {
      return _.map(response, value => {
        return value.Symbol
      })
    })

Service response is

//console.log(response)
    0:{UserId: "michael", Symbol: "ABC"}
    1:{UserId: "michael", Symbol: "ABD"}
    2:{UserId: "michael", Symbol: "XYZ"}
    3:{UserId: "michael", Symbol: "ZYX"}
    4:{UserId: "michael", Symbol: "CBA"}

in console.log I'm getting a promise response, which I don't understand why

//console.log(info)
Promise {_bitField: 0, _fulfillmentHandler0: undefined, _rejectionHandler0: undefined, _promise0: undefined, _receiver0: undefined, …} 

The returned symbols are in _rejectionHandler0

My desire return is ['ABC', 'ABD', 'XYZ', 'ZYX', 'CBA']

hammies
  • 1,344
  • 2
  • 22
  • 46
  • what does `getUserInfo` return? – Anthony Jun 21 '18 at 15:22
  • because its a async call, and `getUserInfo` is returning a promise that you can see from console output, check the answer of duplicate ques, you will see all possible ways of fixing that issue :) – Mayank Shukla Jun 21 '18 at 15:30
  • @MayankShukla he was already `.then`ing the return of that function, so I was just curious what the returned `Promise` looked like to see the `resolve` value – Anthony Jun 21 '18 at 17:46
  • @Tony I get the same as //console.log(info) response, showing the promise info and the results inside the promise. – hammies Jun 21 '18 at 18:11

1 Answers1

0

try

const info= getUserInfo('michael').then(response => {
    return _.map(response, value => {
        return value.Ticker
    })
})

you are accessing Symbol which is not on your response. it should be Ticker

caxco93
  • 33
  • 5