/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/javascript/fetch-json/main.js
11 строк
341 B
Spirzen
Init
07 июн 2026, 02:39
07 июн 2026, 02:39
ca7a590
Код
Авторство
О чём код?
export async function loadPosts(limit = 3) { const res = await fetch(`https://jsonplaceholder.typicode.com/posts?_limit=${limit}`); if (!res.ok) { throw new Error(`HTTP ${res.status}`); } return res.json(); } loadPosts() .then((posts) => console.table(posts.map((p) => ({id: p.id, title: p.title})))) .catch(console.error);