Skip to content

Commit

Permalink
Merge pull request #10805 from haffla/develop
Browse files Browse the repository at this point in the history
[FIX] Cannot read property 'debug' of undefined when trying to use REST API
  • Loading branch information
rodrigok authored Jun 4, 2018
2 parents 8f69796 + 3ae85a0 commit c24ac1c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/rocketchat-api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const logger = new Logger('API', {});
class API extends Restivus {
constructor(properties) {
super(properties);
this.logger = new Logger(`API ${ properties.version ? properties.version : 'default' } Logger`, {});
this.authMethods = [];
this.fieldSeparator = '.';
this.defaultFieldsToExclude = {
Expand Down Expand Up @@ -159,12 +158,12 @@ class API extends Restivus {
entrypoint: route
});

this.logger.debug(`${ this.request.method.toUpperCase() }: ${ this.request.url }`);
logger.debug(`${ this.request.method.toUpperCase() }: ${ this.request.url }`);
let result;
try {
result = originalAction.apply(this);
} catch (e) {
this.logger.debug(`${ method } ${ route } threw an error:`, e.stack);
logger.debug(`${ method } ${ route } threw an error:`, e.stack);
result = RocketChat.API.v1.failure(e.message, e.error);
}

Expand All @@ -182,7 +181,7 @@ class API extends Restivus {
}

//Allow the endpoints to make usage of the logger which respects the user's settings
endpoints[method].logger = this.logger;
endpoints[method].logger = logger;
});
}

Expand Down

0 comments on commit c24ac1c

Please sign in to comment.