I just try simple lua code:
local http = require("socket.http")
local b, c, h = http.request("http://www.example.com/")
But I get this error:
stdin:1: attempt to index global 'http' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
luasocket is installed and lua find it, anyone can help?
The lua repl runs each line in its own context. Local variables don't stick around from line to line. Drop the local on the first line and http will be available in the second line in the repl.
If b, c and h are nil that sounds like the call failed for some reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With