nl_tokens: Function : dispatchLocalApiCall This is the core where server side API callbacks are dispatched . It is called by Barefoots <sync > replacement .
pl_tokens: function dispatchLocalApiCall ( httpMethod , url , data , options ) { debug ( 'dispatching local api call (httpMethod: `%s`, url: `%s`)' , httpMethod , url ) ; var self = this , params = { } , matchedRoute = matchRoute ( httpMethod , url , this . apiRoutes , params ) ; options = options || { } ; if ( _ . isUndefined ( matchedRoute ) ) { if ( _ . has ( options , 'error' ) ) { options . error ( new Error ( 'Could not resolve API route: ' + url ) ) ; } else { winston . log ( 'info' , 'Could not resolve API route' , { source : toString ( ) , apiRoute : url } ) ; } } var successHandler = function successHandler ( apiResult ) { if ( _ . has ( options , 'success' ) ) { <mask> . success ( apiResult ) ; } else { winston . log ( 'info' , 'No success callback defined' , { source : self . toString ( ) , apiRoute : url } ) ; } } , errorHandler = function errorHandler ( err ) { var message , stack ; if ( ! _ . isUndefined ( err ) ) { message = err . toString ( ) || err ; stack = err . stack || undefined ; } if ( _ . has ( options , 'error' ) ) { options . error ( err ) ; } else { winston . log ( 'info' , 'No error callback defined' , { source : toString ( ) , apiRoute : url } ) ; } winston . log ( 'error' , 'API callback stopped with error' , { source : self . toString ( ) , apiRoute : url , err : message , stack : stack } ) ; } ; processCallbacks ( _ . values ( params ) , data , this . req , { } , successHandler , errorHandler , matchedRoute . callback ) ; }