File tree 1 file changed +16
-5
lines changed
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -441,20 +441,31 @@ function get_gif(tags, func) {
441
441
"rating" : config . rating ,
442
442
"format" : "json"
443
443
} ;
444
+ var query = qs . stringify ( params ) ;
445
+
444
446
if ( tags !== null ) {
445
- params . tag = tags ;
447
+ query += "&q=" + tags . join ( '+' )
446
448
}
447
449
448
- var query = qs . stringify ( params ) ;
449
- //wouldnt see request lib if defined at the top for some reason:\
450
- var request = require ( "request" ) ;
450
+ //wouldnt see request lib if defined at the top for some reason:\
451
+ var request = require ( "request" ) ;
452
+ //console.log(query)
451
453
452
454
request ( config . url + "?" + query , function ( error , response , body ) {
455
+ //console.log(arguments)
453
456
if ( error || response . statusCode !== 200 ) {
454
457
console . error ( "giphy: Got error: " + body ) ;
458
+ console . log ( error ) ;
459
+ //console.log(response)
455
460
}
456
461
else {
457
- func ( JSON . parse ( body ) . data [ 0 ] . id ) ;
462
+ var responseObj = JSON . parse ( body )
463
+ console . log ( responseObj . data [ 0 ] )
464
+ if ( responseObj . data . length ) {
465
+ func ( responseObj . data [ 0 ] . id ) ;
466
+ } else {
467
+ func ( undefined ) ;
468
+ }
458
469
}
459
470
} . bind ( this ) ) ;
460
471
}
You can’t perform that action at this time.
0 commit comments