File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -31,13 +31,14 @@ function createApp(reqParams: ReqParams, handler: HandlerFunc) {
3131
3232 if ( ! proceed ) {
3333 res . statusCode = 401 ;
34- res . json ( {
34+ return res . json ( {
3535 message : "unauthenticated request" ,
3636 } ) ;
3737 }
38- next ( ) ;
38+
39+ // if user has manually responded then skip going further
40+ if ( ! res . headersSent ) next ( ) ;
3941 } catch ( e ) {
40- console . log ( "error is" , e ) ;
4142 res . statusCode = 400 ;
4243 res . json ( {
4344 message : "something went wrong" ,
@@ -55,7 +56,11 @@ function createApp(reqParams: ReqParams, handler: HandlerFunc) {
5556
5657 res . send ( { data } ) ;
5758 } catch ( e ) {
58- console . log ( "error is" , e ) ;
59+ res . statusCode = 400 ;
60+ res . json ( {
61+ message : "something went wrong" ,
62+ error : e . message ,
63+ } ) ;
5964 }
6065 } ) ;
6166
You can’t perform that action at this time.
0 commit comments