Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Passing additional parameters to the http.request 'success' callback function? Possible?

edited May 2014 in General Posts: 398

I've never done much with http.request up until now, but I'm trying to work out if its possible to pass additional parameters to the 'success' (or fail!) function to modify its behaviour.

I've tried all the usual Lua tricks but can't seem to get it to do what I want. I'm sure its something really easy that i've overlooked!

Anyone have any thoughts? :-/


  • Posts: 1,976

    How about something like this?

    function setup()
        websites = {"", ""}
        for i = 1, #websites do
            http.request(websites[i], function(...) success(i, ...) end)
    function success(i, data, status, headers)
        print(websites[i] .. " returned with a status of " .. status)
  • Posts: 398

    Thats it! @SkyTheCoder - Perfect and elegant!

    I figured it was some combination of using the variable arg list identifier (...), but completely forgot about nesting it in a function!

    Thank you sir! Very useful!

Sign In or Register to comment.