How can I generate a random word?
I was thinking of doing a ‘post request’ from http://watchout4snakes.com/wo4snakes/Random/RandomWord
but im not sure how to.
nvm, This works:
01 | local HttpService = game:GetService( "HttpService" ) |
02 |
03 | local function randomword() |
04 |
05 | local response = HttpService:RequestAsync( |
06 |
07 | { |
08 |
09 | Url = "http://watchout4snakes.com/wo4snakes/Random/RandomWord" , -- This website helps debug HTTP requests |
10 |
11 | Method = "POST" , |
12 |
13 | Headers = { |
14 |
15 | [ "Content-Type" ] = "application/json" |
16 |
17 | } , |
18 |
19 | Body = HttpService:JSONEncode( { hello = "world" } ) |
20 |
21 | } |
22 |
23 | ) |
24 |
25 | -- Inspect the response table |
26 |
27 | if response.Success then |
28 |
29 | return (response.Body) |
30 |
31 | else |
32 |
33 | print ( "The request failed:" , response.StatusCode, response.StatusMessage) |
34 |
35 | end |
36 |
37 | end |
38 |
39 | local success, message = pcall (randomword) |
40 |
41 | if not success then |
42 |
43 | print ( "Http Request failed:" , message) |
44 |
45 | end |
46 |
47 |
48 |
49 |
50 | print (randomword()) |