Im creating an ImGui gui which should post JSON body but it doesnt send the request
ImGui::BeginChild("Config", ImVec2(0, 0), ImGuiChildFlags_Border);
{
ImAdd::SeparatorText("Config Options");
if (ImGui::Button("Load Config")) {
std::cout << "Button clicked" << std::endl;
nlohmann::json config;
config["velocity"]["enabled"] = velocity::enabled;
config["velocity"]["velocityV"] = velocity::velocityV;
config["velocity"]["velocityH"] = velocity::velocityH;
config["speed"]["enabled"] = speed::enabled;
config["aim"]["enabled"] = aim::enabled;
config["aim"]["aim_distance"] = aim::aim_distance;
config["aim"]["aim_speed"] = aim::aim_speed;
config["aim"]["max_angle"] = aim::max_angle;
config["leftClicker"]["enabled"] = leftClicker::enabled;
config["leftClicker"]["minCPS"] = leftClicker::minCPS;
config["leftClicker"]["maxCPS"] = leftClicker::maxCPS;
config["rightClicker"]["enabled"] = rightClicker::enabled;
config["rightClicker"]["minCPS"] = rightClicker::minCPS;
config["rightClicker"]["maxCPS"] = rightClicker::maxCPS;
SendConfigToServer(config, "(uuid)");
}
}```
SendConfigToServer function:
```cpp
void SendConfigToServer(const nlohmann::json& config, const std::string& player_uuid) {
CURL* curl;
CURLcode res;
std::string url = "https://mydomain/api/config";
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
std::string json_data = config.dump();
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
std::string uuid_header = "x-player-uuid: " + player_uuid;
headers = curl_slist_append(headers, uuid_header.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "Request failed: " << curl_easy_strerror(res) << std::endl;
}
else {
std::cout << "Config successfully sent!" << std::endl;
}
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
}
curl_global_cleanup();
}```