Created
June 11, 2023 01:00
-
-
Save luizcalaca/56a68a6c1bc48de4fdadb663a0764043 to your computer and use it in GitHub Desktop.
Node.js 20 - native fetch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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