summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-20 17:24:10 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-20 17:24:10 +0800
commitdbff318c05e124c5a1fcf4d41f0386735a0796f9 (patch)
tree21b2d0a77b5340acecce2f6444c7a69b824a65cb /main.c
parent648d4ba2964a71e06f9675ee20d9e250d5fc88d1 (diff)
Path name is now relative
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/main.c b/main.c
index b5ea6f1..7b55ee1 100644
--- a/main.c
+++ b/main.c
@@ -2,6 +2,12 @@
#include <string.h>
#include <emscripten/fetch.h>
+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");
}