diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-20 18:07:36 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-09-20 18:07:36 +0800 |
commit | fa643f65ad35108e018a35e50c71364334dbc82e (patch) | |
tree | b78e0c312d2deecb0ac116dfd910c7e8bc6d4143 /main.c | |
parent | dbff318c05e124c5a1fcf4d41f0386735a0796f9 (diff) |
Revert "Path name is now relative"
This reverts commit dbff318c05e124c5a1fcf4d41f0386735a0796f9.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -2,12 +2,6 @@ #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]; @@ -24,7 +18,7 @@ static void handle_error(emscripten_fetch_t *fetch) emscripten_fetch_close(fetch); } -void getproducts(const char *token) +void getproducts(const char *token, const char *app_url) { emscripten_fetch_attr_t attr; emscripten_fetch_attr_init(&attr); @@ -36,5 +30,14 @@ void getproducts(const char *token) char auth[strlen(schema) + strlen(token) + 1]; sprintf(auth, "%s%s", schema, token); attr.requestHeaders = (const char *[]){ "Authorization", auth, NULL }; - emscripten_fetch(&attr, "products"); + 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; } |