I'm making a dashboard with some coin values (in this case, bitcoin (BTC) and NLG.) I am getting the current value of BTC from bitstamp, I want to get the NLG to BTC value from Bittrex. I made the following page: (you can also find it here: (I'll remove it at some point) http://coin.hmrt.nl/)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Coin.hmrt.nl</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Coin.hmrt.nl</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#NLG-BTC">NLG-BTC</a></li>
<li><a href="#NLG">NLG</a></li>
<li><a href="#BTC">BTC</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container" id="NLG-BTC">
<section>
<h2>NLG-BTC</h2>
<div class="row row-eq-height">
<div class = col-md-4>
<h4>Huidige waarden</h4>
<p class="BTC_EUR">BTC(€): </p>
<p class="greeting-content">NLG(€): </p>
<p class="NLG_BTC">NLG(BTC): </p>
</div>
<div class = col-md-4>
<p class="last-bid">The API result is </p>
<p>1</p>
</div>
<div class = col-md-4>
<img src="grafiek.jpg">
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="hello.js"></script>
<script src="get_values.js"></script>
<script src="get_values2.js"></script>
</body>
</html>
For now I split the javascript in two because the bittrex api call does not work, it keeps the bitstamp one from loading its value. These are the javascripts, the first one works.
$(document).ready(function() {
$.ajax({
url: "https://www.bitstamp.net/api/v2/ticker/btceur"
}).then(function(response_BTC_EUR) {
var BTC_EUR = response_BTC_EUR.last;
$('.BTC_EUR').append(BTC_EUR);
url: "http://rest-service.guides.spring.io/greeting"
}).then(function(data) {
$('.greeting-id').append(data.id);
$('.greeting-content').append(data.content);
});
});
and this one does not give an output:
$(document).ready(function() {
$.ajax({
url: "https://bittrex.com/api/v1.1/public/getticker?market=BTC-NLG"
}).then(function(response_NLG_BTC) {
console.log(response_NLG_BTC)
var NLG_BTC = response_NLG_BTC
$('.NLG_BTC').append(NLG_BTC.result);
});
});
In Python I have all APIs working, this code for example works:
requests.get('https://bittrex.com/api/v1.1/public/getticker?market=BTC-NLG').json()
It produces:
{'message': '',
'result': {'Ask': 1.1e-05, 'Bid': 1.099e-05, 'Last': 1.099e-05},
'success': True}
What am I missing? I also find it quite difficult or actually impossible to debug because I have no feedback anywhere on what goes wrong. Any ideas?