mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 17:52:16 +00:00
Update network.js
This commit is contained in:
@@ -362,4 +362,61 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
LiteGraph.registerNodeType("network/sillyclient", LGSillyClient);
|
LiteGraph.registerNodeType("network/sillyclient", LGSillyClient);
|
||||||
|
|
||||||
|
//HTTP Request
|
||||||
|
function HTTPRequestNode() {
|
||||||
|
this.addInput("request", LiteGraph.ACTION);
|
||||||
|
this.addInput("url", "string");
|
||||||
|
this.addProperty("url", "string");
|
||||||
|
this.addOutput("ready", LiteGraph.EVENT);
|
||||||
|
this.addOutput("data", "string");
|
||||||
|
this._data = null;
|
||||||
|
this._fetching = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPRequestNode.title = "HTTP Request";
|
||||||
|
HTTPRequestNode.desc = "Fetch data through HTTP";
|
||||||
|
|
||||||
|
HTTPRequestNode.prototype.fetch = function()
|
||||||
|
{
|
||||||
|
this.boxcolor = "#FF0";
|
||||||
|
var that = this;
|
||||||
|
this._fetching = fetch(url)
|
||||||
|
.then(resp=>{
|
||||||
|
if(!resp.ok)
|
||||||
|
{
|
||||||
|
this.boxcolor = "#F00";
|
||||||
|
that.trigger("error");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.boxcolor = "#0F0";
|
||||||
|
return resp.text();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(data=>{
|
||||||
|
that._data = data;
|
||||||
|
that._fetching = null;
|
||||||
|
that.trigger("ready");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPRequestNode.prototype.onAction = function(evt)
|
||||||
|
{
|
||||||
|
if(evt == "request")
|
||||||
|
this.fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
HTTPRequestNode.prototype.onExecute = function() {
|
||||||
|
this.setOutputData(1, this._data);
|
||||||
|
};
|
||||||
|
|
||||||
|
HTTPRequestNode.prototype.onGetOutputs = function() {
|
||||||
|
return [["error",LiteGraph.EVENT]];
|
||||||
|
}
|
||||||
|
|
||||||
|
LiteGraph.registerNodeType("network/httprequest", HTTPRequestNode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})(this);
|
})(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user