max-mapper/callback-hell

Can you add some words on how callback arguments get set

rickschmoo opened this issue · 0 comments

Thanks for doing this!

Something which throws me whenever I look at callback code, is where the "err, response, body" arguments to postResponse come from. I feel like this is a stumbling block for many people. Thanks again!

  var name = document.querySelector('input').value
  request({
    uri: "http://example.com/upload",
    body: name,
    method: "POST"
  }, postResponse)
}

function postResponse(**err, response, body**) { // <<<<<< here
  var statusMessage = document.querySelector('.status')
  if (err) return statusMessage.value = err
  statusMessage.value = body
}
document.querySelector('form').onsubmit = formSubmit