AFB.js: Improve default token discovery 37/21937/1
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 9 Jul 2019 15:27:03 +0000 (17:27 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 23 Jul 2019 12:18:41 +0000 (14:18 +0200)
The example script AFB.js should look int the URLs
of the page if the token is set or not and then use it.

Bug-AGL: SPEC-2661

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I4adba8eac214130b425b6cd3c56fc1dc63543011

test/AFB.js

index 6564843..4c500b9 100644 (file)
@@ -21,7 +21,7 @@ if (typeof base != "object")
 
 var initial = {
        base: base.base || "api",
-       token: base.token || initialtoken || "HELLO",
+       token: initialtoken || base.token || URLSearchParams(window.location.search).get('token') || "HELLO",
        host: base.host || window.location.host,
        url: base.url || undefined
 };