Exercise 11.4 (Bonus)
This is Exercise 11.4, lecture on communicating with backend, used in the
course
IDATA2301 Web technologies
at NTNU, campus Aalesund.
Go back to exercise list.
Purpose
This is a bonus exercise for especially curious and active students :).
Instructions
If you are done and have some time left, use the time creatively! For
example:
-
Display a
real dice
instead of a number.
-
Allow the user to throw multiple dice at once (Yes
both "die" and "dice" are legit singular forms of the word). Several ways to do it. One of them: if you send an HTTP POST
(instead of a GET) and specify n=X (where X is the number of dice you
want to get, in the range 1..10) to the same API url, you will get a
JSON array back with X dice values, instead of a single value.
-
Explore other options for sending HTTP requests. Did you use
fetch
with promises? Try fetch
with
await
. Or try XmlHttpRequest
.