JSFiddle - React, Tailwind, and code Playground
by klarstil
HTML
<button class="test-me">
Test me
</button>
JavaScript
function fetchPost(id) {
id = id || 1;
var jQueryPromise = $.ajax({
'url': 'https://jsonplaceholder.typicode.com/posts/' + id
});
return Promise.resolve(jQueryPromise);
}
$('.test-me').on('click.test-me', function() {
fetchPost(1).then(function(response) {
alert(JSON.stringify(response));
});
});