Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/embind_with_asyncify.cpp
4128 views
1
#include <assert.h>
2
3
#include <string>
4
5
#include <emscripten.h>
6
#include <emscripten/val.h>
7
8
using namespace emscripten;
9
10
int main() {
11
val fetch = val::global("fetch");
12
std::string url = "data:text/plain,foo";
13
val async_response = fetch(url);
14
val response = async_response.await();
15
val async_text = response.call<val>("text");
16
std::string text = async_text.await().as<std::string>();
17
REPORT_RESULT(text == "foo");
18
}
19
20