lifecycle update
This commit is contained in:
parent
84ce42f106
commit
0b7a43efbd
14 changed files with 950 additions and 490 deletions
|
|
@ -1,17 +1,16 @@
|
|||
import Crafter.CppDOM;
|
||||
import std;
|
||||
using namespace Crafter;
|
||||
using namespace Crafter::CppDOMBindings;
|
||||
|
||||
HtmlElementPtr body("body", "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
|
||||
|
||||
int main(){
|
||||
void* body = GetElementById("body");
|
||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Testing HTTP requests...</p>");
|
||||
|
||||
Fetch("https://httpbin.org/get", [body](std::string result){
|
||||
Fetch("https://httpbin.org/get", [](std::string result){
|
||||
if (!result.empty()) {
|
||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Response: " + result + "</p>");
|
||||
body.SetInnerHTML("<h1>Fetch Example</h1><p>Response: " + result + "</p>");
|
||||
} else {
|
||||
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Failed to fetch data</p>");
|
||||
body.SetInnerHTML("<h1>Fetch Example</h1><p>Failed to fetch data</p>");
|
||||
}
|
||||
FreeJs(body);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue