js_events_api_fetching_cheat_sheet
js_events_api_fetching_cheat_sheet
JavaScript Events:
1. Click Event:
element.addEventListener('click', function() {
});
2. Mouse Event:
element.addEventListener('mouseover', function() {
});
3. Keyboard Event:
element.addEventListener('keydown', function(event) {
});
element.addEventListener('change', function() {
});
form.addEventListener('submit', function(event) {
6. Focus Event:
element.addEventListener('focus', function() {
});
7. Blur Event:
element.addEventListener('blur', function() {
});
API Fetching:
fetch('https://api.example.com/data')
.then(data => {
})
.catch(error => {
});
fetch('https://api.example.com/data', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
})
.then(data => {
})
.catch(error => {
});
fetch('https://api.example.com/data')
.then(data => {
console.log(data);
});
try {
console.log(data);
} catch (error) {
console.error('Error:', error);
fetchData();