Created
July 13, 2015 22:00
-
-
Save markthethomas/8946a1c27c57a6efdced to your computer and use it in GitHub Desktop.
Name example -- calbacks
This file contains 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
'use strict'; | |
require('babel/register'); | |
var ourModule = require('./example'), | |
chalk = require('chalk'); | |
ourModule('Mark', function(err, message) { | |
if (err) { | |
console.error(err); | |
} | |
if (message) { | |
console.log(chalk.green(message)); | |
} | |
}); |
This file contains 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
'use strict'; | |
require('babel/register'); | |
var request = require('request'); | |
module.exports = function(name, done) { | |
var err, message; | |
if (name.split().length > 10) { | |
err = new Error(); | |
message = 'The name you provided was wayyyy tooo long :/'; | |
} else { | |
request.get('http://google.com', (error, response, body) => { | |
if (err) { | |
console.error(err); | |
} | |
if (response.statusCode === 200) { | |
done(err, `Congrats ${name}! You were able to visit the google homepage!!!!!!!!!!!`); | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment