Skip to content
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
18 changes: 12 additions & 6 deletions src/shared/topcoder/challenges.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class TopcoderChallengesService {
}
});

this.logger.log(`Fetching challenges from: ${url.toString()}`);
const stringUrl = url.toString();
this.logger.log(`Fetching challenges from: "${stringUrl}"`);

const headers: Record<string, string> = {
'Content-Type': 'application/json',
Expand All @@ -35,12 +36,17 @@ export class TopcoderChallengesService {
}

this.logger.log(
`Fetching challenges with headers: ${JSON.stringify(headers)}`,
`Fetching challenges with headers: "${JSON.stringify(headers)}"`,
);

return fetch(url.toString(), {
method: 'GET',
headers,
});
try {
return await fetch(stringUrl, {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high
correctness
The await keyword is used here, but the function is not marked as async. This will result in a syntax error. Ensure the function is declared as async to handle the await correctly.

method: 'GET',
headers,
});
} catch (error) {
this.logger.error(`Error fetching challenges: ${JSON.stringify(error)}`, error);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium
readability
Consider using error.message instead of JSON.stringify(error) for logging the error message. JSON.stringify might not serialize the error object as expected, leading to loss of information.

throw error;
}
}
}