From dbff318c05e124c5a1fcf4d41f0386735a0796f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Tue, 20 Sep 2022 17:24:10 +0800 Subject: Path name is now relative --- index.html | 4 ++-- main.c | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index b9246c9..37b1af9 100644 --- a/index.html +++ b/index.html @@ -18,9 +18,9 @@ .createApp({ apiKey: '%s', host: '%s' - })), '%s'); + }))); } - + diff --git a/main.c b/main.c index b5ea6f1..7b55ee1 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,12 @@ #include #include +int main(int argc, char *argv[]) +{ + EM_ASM(getToken()); + return 0; +} + static void handle_success(emscripten_fetch_t *fetch) { char data[fetch->numBytes + 1]; @@ -18,7 +24,7 @@ static void handle_error(emscripten_fetch_t *fetch) emscripten_fetch_close(fetch); } -void getproducts(const char *token, const char *app_url) +void getproducts(const char *token) { emscripten_fetch_attr_t attr; emscripten_fetch_attr_init(&attr); @@ -30,14 +36,5 @@ void getproducts(const char *token, const char *app_url) char auth[strlen(schema) + strlen(token) + 1]; sprintf(auth, "%s%s", schema, token); attr.requestHeaders = (const char *[]){ "Authorization", auth, NULL }; - static const char *path = "/products"; - char url[strlen(app_url) + strlen(path) + 1]; - sprintf(url, "%s%s", app_url, path); - emscripten_fetch(&attr, url); -} - -int main(int argc, char *argv[]) -{ - EM_ASM(getToken()); - return 0; + emscripten_fetch(&attr, "products"); } -- cgit v1.2.3