Last active
May 28, 2018 08:54
-
-
Save goFrendiAsgard/bbfdac5b53c698a0e0f7df74be8c4e1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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