Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Cannot read property 'debug' of undefined when trying to use REST API #10805

Merged
merged 3 commits into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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