I want to link with the api but this link (https://api.fm-track.com/object-coordinates-stream.json?version=2&api_key=1g6F9NvaKY4jsnmrLqmzxILIMhTpncwr) every time I try to link it with my site
I can't why
this code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/css?family=Dosis:400,700" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$.ajax({
url: "https://api.fm-track.com/object-coordinates-stream.json?version=2&api_key=1g6F9NvaKY4jsnmrLqmzxILIMhTpncwr",
type: "GET",
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
}
});
});
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
CodePudding user response:
Nothing wrong with your code, your problem is your API URL, it doesn't respond.
Check this out
$(document).ready(function() {
$.ajax({
url: "https://api.weather.gov/points/39.7456,-97.0892",
type: "GET",
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
}
});
});
<link href="https://fonts.googleapis.com/css?family=Dosis:400,700" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
CodePudding user response:
The response from your API looks wield.
It doesn't belong to the array, JSON, or any other efficient data type. You should improve the API.
// E.g. API return an array
[{"object_id":"AAAAAA", "datetime":"aaa", ..., "weight":"0.00"},{"object_id":"BBBB", "datetime":"bbb", ..., "weight":"0.00"}, ..., {...}]