Hello Guest

HTTP Request

  • 1 Replies
  • 107 Views
*

alerin

  • *
  • 1
  • +0/-0
    • View Profile
HTTP Request
« on: October 15, 2019, 10:24:23 pm »
Hello,

I need make an http request at DiceBot code, i tried this:

hc = require('httpclient').new()
res = hc:get('https://freebitco.in/cf_stats_public/?f=updating2')
if res.body then
  print(res.body)
else
  print(res.err)
end

But returns this error:

LUA ERROR!!
Index was outside the bounds of the array.

I downloaded the httpclient on it: https://github.com/lusis/lua-httpclient/tree/master/src

Please help

Thank you.
« Last Edit: October 15, 2019, 10:27:00 pm by alerin »

*

Seuntjie

  • *****
  • 352
  • +11/-2
    • View Profile
Re: HTTP Request
« Reply #1 on: October 22, 2019, 08:19:42 pm »
Hello,

I need make an http request at DiceBot code, i tried this:

hc = require('httpclient').new()
res = hc:get('https://freebitco.in/cf_stats_public/?f=updating2')
if res.body then
  print(res.body)
else
  print(res.err)
end

But returns this error:

LUA ERROR!!
Index was outside the bounds of the array.

I downloaded the httpclient on it: https://github.com/lusis/lua-httpclient/tree/master/src

Please help

Thank you.

I'm not sure the version of lua the bot uses supports the require function. If you have the lua files for the http client, try using dofile with the file it references instead. I can't guarantee it'll work though.