11th Mar 2018, 8:31 AM
Sina
Sina - avatar
13 Answers
+ 5
Make this your JavaScript code: navigator.getBattery().then(function(battery) { document.write(battery.level * 100); } )
11th Mar 2018, 2:19 PM
John Wells
John Wells - avatar
11th Mar 2018, 8:52 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 3
You call it via the promise getBattery returns with a success function to be called when the promise is fulfilled. Basically, battery needs to be looked up so you make a request with getBattery. At some point later, the data becomes available. You use then to say, when it is available call this function.
11th Mar 2018, 5:11 PM
John Wells
John Wells - avatar
+ 3
No. That is the method to tell the promise here is my function you should call once you get the data.
11th Mar 2018, 5:15 PM
John Wells
John Wells - avatar
+ 2
Make what?
11th Mar 2018, 5:16 PM
John Wells
John Wells - avatar
+ 1
Plz if you can Make it true I want a very simple example to underestand
11th Mar 2018, 9:40 AM
Sina
Sina - avatar
+ 1
Sorry what does ".then" do in this code??
11th Mar 2018, 5:03 PM
Sina
Sina - avatar
+ 1
I'll get happy if you answer
11th Mar 2018, 5:03 PM
Sina
Sina - avatar
+ 1
What is then??Can you make an example with that untill O underestand that
11th Mar 2018, 5:06 PM
Sina
Sina - avatar
+ 1
So can you make a code like that code without .then??
11th Mar 2018, 5:13 PM
Sina
Sina - avatar
+ 1
would you make .?
11th Mar 2018, 5:15 PM
Sina
Sina - avatar
+ 1
Ok thanks
11th Mar 2018, 5:16 PM
Sina
Sina - avatar
+ 1
nothing
11th Mar 2018, 5:17 PM
Sina
Sina - avatar