Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. const UserProfile = function(id, callback) { // callback atau cb
  2. if (!id){
  3. return callback(new Error('Invalid userId')) // syntax to create error
  4. }
  5. let response = {
  6. success: true,
  7. id: id,
  8. message: 'User Found'
  9. }
  10. return callback(null, response)
  11. }
  12.  
  13. UserProfile(null,function(err,result){
  14. if (!err){
  15. console.log(result)
  16. }
  17. else{
  18. console.log(err.message)
  19. }
  20. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement