function fetchVideos(callback) {
setTimeout(() => {
const data = [
{ id: 1, title: "Топ 10 игр 2023" },
{ id: 2, title: "Лучшая битва в Warcraft3" },
{ id: 3, title: "Чем кормить кошек" },
];
callback(data);
}, 1000);
}
function fetchVideoDesc(id, callback) {
setTimeout(() => {
const description = {
id: 1,
title: "Топ 10 игр 2023",
hashTags: ["игры", "2023"],
authorId: 55,
};
callback(description);
}, 1000);
}
function fetchAuthor(authorId, callback) {
setTimeout(() => {
const author = {
id: 55,
name: "Какие-то уроки",
videoIds: [1, 2, 3],
shortIds: [10, 15, 33],
};
callback(author);
}, 1000);
}
function fetchAuthorShorts(author) {
setTimeout(() => {
console.log(author.shortIds[1]);
});
}
function run() {
fetchVideos((videos) => {
fetchVideoDesc(videos[0].id, (desc) => {
fetchAuthor(desc.authorId, (author) => {
fetchAuthorShorts(author);
});
});
});
}
run();