fengari-lua/fengari

io library missing?

FrancoisMentec opened this issue · 1 comments

Apparently, io is nil: attempt to index a nil value (global 'io').
How could I access io to read a file hosted by my server? I'm trying to run an external project, I can't change the code to use something different than io. I tried something like:

io = {}

function io:open (fileName , mode)
  return {
    read = function () return loadfile("/path/" .. fileName) end,
    close = function () end
  }
end

But fileName is equals to r (the opening mode), and mode is nil.

See https://github.com/fengari-lua/fengari#missing-features:

The following functions are only available in Node:

  • The entire io lib

How could I access io to read a file hosted by my server?

Running in the browser, the io lib would access the user's filesystem, not the servers, so you're looking in the wrong place anyway :P
To access a file hosted on a HTTP server... you make a http request! You'd probably want to look at the browser fetch API.