I need to know the current URL from PebbleKit Javascript, my code is like follows:
Pebble.addEventListener("ready",
function(e) {
console.log("JS Ready");
var req = new XMLHttpRequest();
req.open('GET', URL_MAIN, true);
req.onload = function(e) {
console.log("Status returned: " + req.status); // status is 404
console.log(window.location.href);
console.log(location);
console.log(window.location.host);
console.log(document.URL);
console.log(document.baseURI);
console.log(window.location);
console.log(JSON.stringify(Pebble)); // returns {}
//var response = JSON.parse(req.responseText);
//console.log
//console.log(response.redirectUrl);
console.log(req.redirectUrl);
console.log(req.getResponseHeader('Location')); // This returns null
console.log(JSON.stringify(e)); // Nothing about the url
}
req.send(null);
}
);
I tried some tests but no one returned me the current url. window.location.href and others returns this:
pebble-js-app.js:13 file:///android_asset/jskit_startup.html?params=%7B%22loadUrl%22%3A%22file%3A%5C%2F%5C%2F%5C%2Fdata%5C%2Fdata%5C%2Fcom.getpebble.android%5C%2Fapp_jskit_installed_apps%5C%2FTelepizza__1%5C%2Fpebble-js-app.js%22%7D
The use case is this:
- I need to open the first URL (that has a 302 redirect).
- Later, with this URL I can starting to make requests.
There is some way to get the current URL from Pebble Javascript?