summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html4
-rw-r--r--main.c19
2 files changed, 13 insertions, 10 deletions
diff --git a/index.html b/index.html
index 37b1af9..b9246c9 100644
--- a/index.html
+++ b/index.html
@@ -18,9 +18,9 @@
.createApp({
apiKey: '%s',
host: '%s'
- })));
+ })), '%s');
}
</script>
- <script type="text/javascript" src="main.js"></script>
+ <script type="text/javascript" src="%s/js/main.js"></script>
</body>
</html>
diff --git a/main.c b/main.c
index 7b55ee1..b5ea6f1 100644
--- a/main.c
+++ b/main.c
@@ -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;
}