From b6fc1703995195af611532cdffda52c86993e4ce Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 11 Apr 2025 16:27:55 -0400 Subject: [PATCH] can't seem to use fetch api --- CMakeLists.txt | 2 +- src/blt/std/requests.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 331c846..153bcfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 5.3.0) +set(BLT_VERSION 5.3.1) set(BLT_TARGET BLT) diff --git a/src/blt/std/requests.cpp b/src/blt/std/requests.cpp index 130e4d6..2ae7d59 100644 --- a/src/blt/std/requests.cpp +++ b/src/blt/std/requests.cpp @@ -85,10 +85,11 @@ namespace blt::requests std::string send_get_request(const std::string& url) { #ifdef __EMSCRIPTEN__ - auto* str = static_cast(EM_ASM_PTR( - { const v = await fetch('$0', { 'credentials': 'omit', 'headers': { 'User-Agent': - 'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0', 'Accept': '/', 'Accept-Language': 'en-US,en;q=0.5', - 'Priority': 'u=4' }, 'method': 'GET', 'mode': 'cors' }); if (!v.ok) { throw v.status; } return stringToNewUTF8(await response.text()); + auto* str = static_cast(EM_ASM_PTR({ + var xhr = new XMLHttpRequest(); + xhr.open("GET", $0); + xhr.send(); + return stringToNewUTF8(xhr.responseText); }, url.c_str())); std::string str_obj{str}; free(str);