Skip to content

Instantly share code, notes, and snippets.

@luizcalaca
Created June 11, 2023 01:00
Show Gist options
  • Save luizcalaca/56a68a6c1bc48de4fdadb663a0764043 to your computer and use it in GitHub Desktop.
Save luizcalaca/56a68a6c1bc48de4fdadb663a0764043 to your computer and use it in GitHub Desktop.
Node.js 20 - native fetch
async function fetchData() {
try {
const response = await fetch('https://api.spacexdata.com/v4/launches/latest');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('Data:', data);
} catch (error) {
console.log('Error:', error);
}
}
fetchData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment