Mostly working with Java so when I came across this code:
document.querySelector('form').onsubmit = formSubmit
function formSubmit (submitEvent) {
var name = document.querySelector('input').value
request({
uri: "http://example.com/upload",
body: name,
method: "POST"
}, postResponse)
}
function postResponse (err, response, body) {
var statusMessage = document.querySelector('.status')
if (err) return statusMessage.value = err
statusMessage.value = body
}
Question is why are we using postResponse in formSubmit when the function is postResponse (err, response, body). When we are using postResponse how does it know which parameters are err, response and body?
Thanks.