18 lines
No EOL
608 B
C++
18 lines
No EOL
608 B
C++
import Crafter.CppDOM;
|
|
import std;
|
|
using namespace Crafter::CppDOMBindings;
|
|
|
|
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){
|
|
std::cout << "callback recieved2" << std::endl;
|
|
if (!result.empty()) {
|
|
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Response: " + result + "</p>");
|
|
} else {
|
|
SetInnerHTML(body, "<h1>Fetch Example</h1><p>Failed to fetch data</p>");
|
|
}
|
|
FreeJs(body);
|
|
});
|
|
} |