-2

I will please need another pair of eyes on this. I am getting historical data from cryptocompare API and can't access the values I receive.

Response

When I hardcode it, something like res.data.OMG.USD, I am able to get the result.

These is the exact format it comes in. I tried parsing it into a string and pushing the results into an array but haven't been able to access the prices, when I did Object.key, it returned only the name and not the USD or EUR values. What am I missing here?

UPDATE:here is the request, I am trying to access the USD values.

 $http.get(
        'data/pricehistorical?fsym=BTC&tsyms=USD,EUR'
          ).then(
            function(res) {
           //sample response
          /*

          {"OMG":{"USD":8.19,"EUR":6.65}}
          {"BTC":{"USD":10226.86,"EUR":8153.29}}
          */
     },

  function(res) {
        console.log(res);
      }
    );

1 Answers1

0

First of all try to understand what JSON format is.

Supposing that you have already studied it then writing pure Javascript code:

var testObject = {"OMG": {"USD": 15.85, "EUR": 12.62}};

//Then you can access USD by

console.log(testObject.OMG.USD);