Created
September 15, 2017 15:02
-
-
Save douglas-mason/935c7bd94a93570826831fa866a96361 to your computer and use it in GitHub Desktop.
callback example
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
const app = { | |
get: (route, cb) => { | |
console.log('sending user to this route:' + route); | |
const req = { | |
user: 'Doug' | |
}; | |
const res = { | |
author: 'Annie', | |
sendData: (data) => { | |
console.log('sending this data -> ' + JSON.stringify(data)) | |
} | |
}; | |
cb(req, res); | |
} | |
}; | |
app.get('/user', (req, res) => { | |
res.sendData('the user is -> ' + req.user); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment