can't seem to use fetch api
parent
e2dc35fea9
commit
b6fc170399
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
set(BLT_VERSION 5.3.0)
|
set(BLT_VERSION 5.3.1)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,11 @@ namespace blt::requests
|
||||||
std::string send_get_request(const std::string& url)
|
std::string send_get_request(const std::string& url)
|
||||||
{
|
{
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
auto* str = static_cast<char*>(EM_ASM_PTR(
|
auto* str = static_cast<char*>(EM_ASM_PTR({
|
||||||
{ const v = await fetch('$0', { 'credentials': 'omit', 'headers': { 'User-Agent':
|
var xhr = new XMLHttpRequest();
|
||||||
'Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0', 'Accept': '/', 'Accept-Language': 'en-US,en;q=0.5',
|
xhr.open("GET", $0);
|
||||||
'Priority': 'u=4' }, 'method': 'GET', 'mode': 'cors' }); if (!v.ok) { throw v.status; } return stringToNewUTF8(await response.text());
|
xhr.send();
|
||||||
|
return stringToNewUTF8(xhr.responseText);
|
||||||
}, url.c_str()));
|
}, url.c_str()));
|
||||||
std::string str_obj{str};
|
std::string str_obj{str};
|
||||||
free(str);
|
free(str);
|
||||||
|
|
Loading…
Reference in New Issue