File tree Expand file tree Collapse file tree 1 file changed +23
-13
lines changed
libraries/nestjs-libraries/src/integrations/social Expand file tree Collapse file tree 1 file changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export class RedditProvider extends SocialAbstract implements SocialProvider {
7676 access_token : accessToken ,
7777 refresh_token : refreshToken ,
7878 expires_in : expiresIn ,
79- scope
79+ scope,
8080 } = await (
8181 await this . fetch ( 'https://www.reddit.com/api/v1/access_token' , {
8282 method : 'POST' ,
@@ -300,18 +300,28 @@ export class RedditProvider extends SocialAbstract implements SocialProvider {
300300 )
301301 ) . json ( ) ;
302302
303- const newData = await (
304- await this . fetch (
305- `https://oauth.reddit.com/${ data . subreddit } /api/link_flair_v2` ,
306- {
307- method : 'GET' ,
308- headers : {
309- Authorization : `Bearer ${ accessToken } ` ,
310- 'Content-Type' : 'application/x-www-form-urlencoded' ,
311- } ,
312- }
313- )
314- ) . json ( ) ;
303+ // eslint-disable-next-line no-async-promise-executor
304+ const newData = await new Promise < { id : string , name : string } [ ] > ( async ( res ) => {
305+ try {
306+ const flair = await (
307+ await this . fetch (
308+ `https://oauth.reddit.com/${ data . subreddit } /api/link_flair_v2` ,
309+ {
310+ method : 'GET' ,
311+ headers : {
312+ Authorization : `Bearer ${ accessToken } ` ,
313+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
314+ } ,
315+ }
316+ )
317+ ) . json ( ) ;
318+
319+ res ( flair ) ;
320+ }
321+ catch ( err ) {
322+ return res ( [ ] ) ;
323+ }
324+ } ) ;
315325
316326 return {
317327 subreddit : data . subreddit ,
You can’t perform that action at this time.
0 commit comments