从javascript进行JSON API调用

时间:2018-11-11 23:58:48

标签: javascript json api

我想从cryptocompare的API调用“ ImageUrl”,并在网络浏览器中显示从API接收的图像。这就是我到目前为止所得到的。

<!DOCTYPE >
<html>
<header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</header>
<body>    
    <script>   
        $.get("https://min-api.cryptocompare.com/data/coin/generalinfo?fsyms=BTC&tsym=USD",function(data){
            console.log(data["Data"]["CoinInfo"]["ImageUrl"]);    
        });  
    </script>
</body>
</html>

它找不到ImageUrl,不知道为什么。我希望有人能帮助我。

这是我叫的api:

    {  
   "Message":"Success",
   "Type":100,
   "Data":[  
      {  
         "CoinInfo":{  
            "Id":"1182",
            "Name":"BTC",
            "FullName":"Bitcoin",
            "Internal":"BTC",
            "ImageUrl":"/media/19633/btc.png",
            "Url":"/coins/btc/overview",
            "Algorithm":"SHA256",
            "ProofType":"PoW",
            "NetHashesPerSecond":51428758524.1138,
            "BlockNumber":549719,
            "BlockTime":600,
            "BlockReward":12.5,
            "Type":1,
            "DocumentType":"Webpagecoinp"
         },
         "ConversionInfo":{  
            "Conversion":"direct",
            "ConversionSymbol":"",
            "CurrencyFrom":"BTC",
            "CurrencyTo":"USD",
            "Market":"CCCAGG",
            "Supply":17371487,
            "TotalVolume24H":218360.5779063504,
            "SubBase":"5~",
            "SubsNeeded":[  
               "5~CCCAGG~BTC~USD"
            ],
            "RAW":[  
               "5~CCCAGG~BTC~USD~4~6379.07~1541979699~0.00619888~39.199733478400006~53580738~19416.555946284025~124251475.2889204~19307.955100854397~123550598.85731664~6396.39~6411.73~6326.38~6398.23~6416.96~6320.79~Coinbase~7ffe9"
            ]
         }
      }
   ]
}

0 个答案:

没有答案