Skip to content

Instantly share code, notes, and snippets.

@douglas-mason
Created September 15, 2017 15:02
Show Gist options
  • Save douglas-mason/935c7bd94a93570826831fa866a96361 to your computer and use it in GitHub Desktop.
Save douglas-mason/935c7bd94a93570826831fa866a96361 to your computer and use it in GitHub Desktop.
callback example
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