Simple user profile with nested objects and arrays
E-commerce product data with arrays and filtering
Complex weather data with nested objects and arrays
Financial data with complex nested structures
Complex order data with nested arrays and objects
Learn how to fetch data from these APIs using JavaScript
// Fetch data from User Data API
fetch('https://www.json-tools.com/api/test/test1')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log('API Response:', data);
// Handle the data here
})
.catch(error => {
console.error('Error fetching data:', error);
});// Fetch data using async/await from User Data API
async function fetchData() {
try {
const response = await fetch('https://www.json-tools.com/api/test/test1');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('API Response:', data);
return data;
} catch (error) {
console.error('Error fetching data:', error);
throw error;
}
}
// Call the function
fetchData();response.ok before parsing JSONtry/catch blocks for error handling