There was a problem fetching the data: SyntaxError: JSON.parse: unexpected character at line 362 column 67 of the JSON data
Here is a simple example using the endpoint.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch and Display JSON</title>
</head>
<body>
<h2>JSON Data from Endpoint:</h2>
<pre id="jsonData"></pre>
<script>
async function fetchDataFromEndpoint() {
try {
// Define the endpoint URL (replace with your own URL)
let url = 'https://health.petals.dev/api/v1/state';
// Fetch data from the endpoint
let response = await fetch(url);
// Check if the request was successful
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
// Convert the response to JSON
let data = await response.json();
// Display the fetched JSON in the <pre> tag
document.getElementById('jsonData').textContent = JSON.stringify(data, null, 2);
} catch (error) {
console.error("There was a problem fetching the data:", error);
document.getElementById('jsonData').textContent = 'Failed to fetch data.';
}
}
// Fetch data when the page loads
window.onload = fetchDataFromEndpoint;
</script>
</body>
</html>
Inspecting the response I noticed that it returns an Infinity value.
Description
Getting error when fetching https://health.petals.dev/api/v1/state endpoint.
Here is a simple example using the endpoint.
Inspecting the response I noticed that it returns an
Infinity
value.