Skip to main content

Posts

Showing posts with the label callback

own function with callback in nodejs

up vote accepted Here's an example of the login function: function login ( username , password , callback ) { var info = { user : username , pwd : password }; request . post ({ url : "https://www.adomain.com/login" , formData : info }, function ( err , response ) { callback ( err , response ); }); } And calling the login function login ( "bob" , "wonderland" , function ( err , result ) { if ( err ) { // login did not succeed } else { // login successful } }); #reference -- stackoverflow