Async & Fetch

Node.js 22では `fetch` が安定版になりました。外部ライブラリは不要です。

Built-in Fetch

Native Fetch
// Node.js 22 Native Fetch
async function getData() {
try {
const res = await fetch('https://api.example.com/data');
const data = await res.json();
console.log(data);
} catch (err) {
console.error('Error:', err);
}
}
getData();