Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: console error

Nevo Davidc84d8af915aa
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
index 63487f511..fbd051f22 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
@@ -290,17 +290,6 @@ export class PostsService {
return this.postSocial(integration, posts, true);
}
- if (
- err instanceof BadBody &&
- process.env.EMAIL_FROM_ADDRESS === '[email protected]'
- ) {
- await this._notificationService.sendEmail(
- 'Bad body',
- JSON.stringify(err.body)
- );
- }
-
throw err;
}
}
diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
index 39034f554..eee510db9 100644
--- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts
+++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts
@@ -1,7 +1,8 @@
-export class RefreshToken {}
+export class RefreshToken {
+ constructor(public json: string, public body: BodyInit) {}
+}
export class BadBody {
- constructor(public body: BodyInit) {
- }
+ constructor(public json: string, public body: BodyInit) {}
}
export class NotEnoughScopes {}
@@ -10,20 +11,23 @@ export abstract class SocialAbstract {
async fetch(url: string, options: RequestInit = {}) {
const request = await fetch(url, options);
- if (request.status !== 200 && request.status !== 201) {
- try {
- console.log(await request.json());
- }
- catch (err) {
- console.log('skip');
- }
+ if (request.status === 200 || request.status === 201) {
+ return request;
}
+
+ let json = '{}';
+ try {
+ json = await request.json();
+ } catch (err) {
+ json = '{}';
+ }
+
if (request.status === 401) {
- throw new RefreshToken();
+ throw new RefreshToken(json, options.body!);
}
if (request.status === 400) {
- throw new BadBody(options.body!);
+ throw new BadBody(json, options.body!);
}
return request;