Skip to content

Instantly share code, notes, and snippets.

@goFrendiAsgard
Last active May 28, 2018 08:54
Show Gist options
  • Select an option

  • Save goFrendiAsgard/bbfdac5b53c698a0e0f7df74be8c4e1d to your computer and use it in GitHub Desktop.

Select an option

Save goFrendiAsgard/bbfdac5b53c698a0e0f7df74be8c4e1d to your computer and use it in GitHub Desktop.
const request = require('request')
function add (n1, n2) {
return n1 + n2
}
// /////////////////////////////////////////////////////////////////////
// First Section
// /////////////////////////////////////////////////////////////////////
console.log('before-add') // 1
let sum = add(4, 5)
console.log(sum) // 2
console.log('after-add') // 3
// /////////////////////////////////////////////////////////////////////
// Second Section
// /////////////////////////////////////////////////////////////////////
console.log('before-request') // 4
request('http://localhost:3000/genres', function (error, response, body) {
console.log('the-real-after-request') // 6
const genres = JSON.parse(body)
console.log(genres) // 7
console.log('after-request-and-parsing') // 8
})
console.log('suppose-to-be-after-request') // 5
/* Output:
before-add
9
after-add
before-request
suppose-to-be-after-request
the-real-after-request
[ { id: 1, name: 'fiction' },
{ id: 2, name: 'history' },
{ id: 3, name: 'science' } ]
after-request-and-parsing
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment