-
• #2
Yes, I think the issue is just that
Bangle.http
returns a promise (it doesn't take a callback as a second argument), but you're not passing that promise back out ofgetPost
.I think all you actually need is the following:
function getPost() { return Bangle.http(serverUrl, { method: 'GET', headers: { 'Authorization': `Basic ${credentials}` } }); }
If there's an error the promise will be rejected, which will be handled by the
.catch
in swipeHandler which I think is kind of what you wanted anyway? -
• #4
Hi,
yesterday i repeatedly connect banglejs2 (with android integration app ) thru BT to android phone (with BJ GB) vs thru BT to laptop.i still cant make my banglejs2 to successfuly use bangle.http i think (as there is no useable data received).
it's annoying to repeated connect and disconnect the BT because not every time it success.
the threshold to use banglejs2 to use bangle.http is quite high.
would you mind to help make it easier?
just illustrate the HW setup: am I correct?
and then is there any simple app that already use bangle.http so if i ran it i know my banglejs2 indeep is working correctly with bangle.http?i wanna make my banglejs2 able to grab the mini bus ETA by "GET".
i have tried it's xxxking easy on python.i really would like some help on this. thank you.
any further tutorials, documents wlll helpful.
i did searched for some post (however they are on reddit) they say the above setup should be ok but i still cant sure the bangle.http is working.thank you.
-
• #5
i already followed others teaching and turned on BJ GB's "internet connection" function etc.
the device just make troubleshooting very troublesome....
thxbtw i did searched that some weather app do use bangle.http,
but we live in different geoplaces i never used that and i am not sure that server will display the info where i live.
so would simply like to have a simple example so i can know my banglejs2 is working with bangle.http,after that, cursor + api documents + AI will help.
thankyou -
• #6
Maybe you can try using the Remote debugging to allow your Bangle to stay connected to Gadgetbridge while you run code: https://www.espruino.com/Gadgetbridge#remote-debugging
Then you can see if there are any error messages when you run the command. There is an example at https://www.espruino.com/Gadgetbridge#http-requests
Bangle.http("https://pur3.co.uk/hello.txt").then(data=>{ console.log("Got ",data); });
Note that you have to use HTTPS, not just HTTP because of Android.
If you want to find other apps, literally just go to the GitHub Bangle.js repo and search for
Bangle.http
: https://github.com/search?q=repo%3Aespruino%2FBangleApps%20Bangle.http&type=code -
• #7
thankyou,
only about 10 apps use bangle.http! and quite many are region specific.however for other learners,
tinyCMC coinmarketcap client <- this app use bangle.http and could demo that it's working.
it keep fetch price of the coins.
I'm currently working on getting my bangle js to send a post request to a webserver and then after a period of time, submit a get request to the webserver, to the retreive the result the first post would cause.
I've tried running a test script to confirm the watch is picking up the get data but I can't get it to display the output onto the screen.
Below is the test script I'm running which I believe should work. Also I've added the getabridge debud logs which (as I understand them) confirm I am at least getting the data from the 'get' request.
Is there an issue with my code approach to getting the output to return correctly, or is there something else I may have missed in the documentation that I need to be doing?
Apologies if it's something to do with the Promie resolution. Still trying to get my head around async functions.