Message from JavaScript discussions

November 2020

— If you don't get cycles, you don't get recursion

— 

I get both
But things like drawing fractals are orders of magnitude more complicated to understand as cycles imho

— I never seen your fractals, so i can't judge🤤

— Believe me, it's the most spaghetti I've ever seen.

It'd be even worse with cycles

— Then master cycles first then move to recursive algos.. my world is simple🤤

— I think I master cycles well enough

— If you don't master cycles, they will master you🤤

— Oh no


You are scaring me


Might as well unroll all of them

— Async cycles even more complicated.. a function call is the end-product, the abyss before that

— Are you reading in my mind? My code is literally async loops

— Hello, I'm stuck with something what is the best way to make an AJAX request with a form to a Rest API? This is wat I have so far now:

const myForm = document.getElementById('loginForm');

myForm.addEventListener('submit', (e) => {
e.preventDefault();

const username = document.getElementById('username').value;
const password = document.getElementById('password').value;

fetch('http://localhost:4000/login', {
method: 'POST',
body: JSON.stringify({
username: username,
password: password
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => {
res.json().then((data) => {
if (res.status === 400) {
document.getElementById('username-group').classList.add('has-error');
document.getElementById('password-group').classList.add('has-error');
}
})
})
.catch(error => console.log(error));
});

Message permanent page

— Is it safe to get the values from the form by this way or not?