File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 362
362
} ;
363
363
364
364
LiteGraph . registerNodeType ( "network/sillyclient" , LGSillyClient ) ;
365
+
366
+ //HTTP Request
367
+ function HTTPRequestNode ( ) {
368
+ this . addInput ( "request" , LiteGraph . ACTION ) ;
369
+ this . addInput ( "url" , "string" ) ;
370
+ this . addProperty ( "url" , "string" ) ;
371
+ this . addOutput ( "ready" , LiteGraph . EVENT ) ;
372
+ this . addOutput ( "data" , "string" ) ;
373
+ this . _data = null ;
374
+ this . _fetching = null ;
375
+ }
376
+
377
+ HTTPRequestNode . title = "HTTP Request" ;
378
+ HTTPRequestNode . desc = "Fetch data through HTTP" ;
379
+
380
+ HTTPRequestNode . prototype . fetch = function ( )
381
+ {
382
+ this . boxcolor = "#FF0" ;
383
+ var that = this ;
384
+ this . _fetching = fetch ( url )
385
+ . then ( resp => {
386
+ if ( ! resp . ok )
387
+ {
388
+ this . boxcolor = "#F00" ;
389
+ that . trigger ( "error" ) ;
390
+ }
391
+ else
392
+ {
393
+ this . boxcolor = "#0F0" ;
394
+ return resp . text ( ) ;
395
+ }
396
+ } )
397
+ . then ( data => {
398
+ that . _data = data ;
399
+ that . _fetching = null ;
400
+ that . trigger ( "ready" ) ;
401
+ } ) ;
402
+ }
403
+
404
+ HTTPRequestNode . prototype . onAction = function ( evt )
405
+ {
406
+ if ( evt == "request" )
407
+ this . fetch ( ) ;
408
+ }
409
+
410
+ HTTPRequestNode . prototype . onExecute = function ( ) {
411
+ this . setOutputData ( 1 , this . _data ) ;
412
+ } ;
413
+
414
+ HTTPRequestNode . prototype . onGetOutputs = function ( ) {
415
+ return [ [ "error" , LiteGraph . EVENT ] ] ;
416
+ }
417
+
418
+ LiteGraph . registerNodeType ( "network/httprequest" , HTTPRequestNode ) ;
419
+
420
+
421
+
365
422
} ) ( this ) ;
You can’t perform that action at this time.
0 commit comments