DEVICE_ID, USERNAME, PASSWORDはご自身の環境に合わせてください。
ajax_get_sigfox_messages.html
<html>
<head>
<title>client</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
function getmessages() {
$.ajax({
url: "https://api.sigfox.com/v2/devices/DEVICE_ID/messages",
success: function(data){
$('#result').html(JSON.stringify(data));
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus+": "+errorThrown);
},
beforeSend: function(xhr) {
var credentials = window.btoa("USERNAME:PASSWORD");
xhr.setRequestHeader("Authorization", "Basic " + credentials);
},
});
}
</script>
</head>
<body>
<button onclick="getmessages();">Get Sigfox Device Messages</button>
<div id="result"></div>
</body>
</html>