JSFiddle - React, Tailwind, and code Playground
by LuckyCat
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
JavaScript
const githubId = 'denis-didenko';
function showError(e) {
console.warn('Error', e);
}
function getUser(id, onSuccess, onFailure) {
$.getJSON({
url: `https://api.github.com/users/${id}`,
success: onSuccess,
error: onFailure,
});
}
function getUserData(user, callback) {
const { name, company } = user;
setTimeout(() => {
callback(name, company);
}, 2000);
}
function showMessage(name, company) {
alert(`${name} works in the company ${company}`);
}
function response (response) {
getUserData(response, showMessage);
}
getUser(githubId, response, showError);