File tree Expand file tree Collapse file tree 2 files changed +16
-23
lines changed
libraries/nestjs-libraries/src Expand file tree Collapse file tree 2 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -290,17 +290,6 @@ export class PostsService {
290290 return this . postSocial ( integration , posts , true ) ;
291291 }
292292
293- if (
294- err instanceof BadBody &&
295- process . env . EMAIL_FROM_ADDRESS === 'nevo@postiz.com'
296- ) {
297- await this . _notificationService . sendEmail (
298- 'nevo@positz.com' ,
299- 'Bad body' ,
300- JSON . stringify ( err . body )
301- ) ;
302- }
303-
304293 throw err ;
305294 }
306295 }
Original file line number Diff line number Diff line change 1- export class RefreshToken { }
1+ export class RefreshToken {
2+ constructor ( public json : string , public body : BodyInit ) { }
3+ }
24export class BadBody {
3- constructor ( public body : BodyInit ) {
4- }
5+ constructor ( public json : string , public body : BodyInit ) { }
56}
67
78export class NotEnoughScopes { }
@@ -10,20 +11,23 @@ export abstract class SocialAbstract {
1011 async fetch ( url : string , options : RequestInit = { } ) {
1112 const request = await fetch ( url , options ) ;
1213
13- if ( request . status !== 200 && request . status !== 201 ) {
14- try {
15- console . log ( await request . json ( ) ) ;
16- }
17- catch ( err ) {
18- console . log ( 'skip' ) ;
19- }
14+ if ( request . status === 200 || request . status === 201 ) {
15+ return request ;
2016 }
17+
18+ let json = '{}' ;
19+ try {
20+ json = await request . json ( ) ;
21+ } catch ( err ) {
22+ json = '{}' ;
23+ }
24+
2125 if ( request . status === 401 ) {
22- throw new RefreshToken ( ) ;
26+ throw new RefreshToken ( json , options . body ! ) ;
2327 }
2428
2529 if ( request . status === 400 ) {
26- throw new BadBody ( options . body ! ) ;
30+ throw new BadBody ( json , options . body ! ) ;
2731 }
2832
2933 return request ;
You can’t perform that action at this time.
0 commit comments