Page 1 of 1

How do I do simple http requests with love/lua?

Posted: Mon Feb 10, 2020 11:46 pm
by cazura
Hello! First, I know Love is not meant for web, so I am sorry if my question should not be asked here.

Here is my issue: I want to get time from http://worldtimeapi.org/

By running

Code: Select all

http = require("socket.http")
tempVar = http.request("http://worldtimeapi.org/api/timezone/Europe/London.txt")
I succefully get the response in love. Now I am also porting to web through love.js, and after the port this same code doesn't work and gives me the error: WebSocket is closed before the connection is established.

Image

I found this love.js git issue which may be relevant, but I'm not sure: https://github.com/TannerRogalsky/love.js/issues/26

So... There is a way to fix it or do it in some other way?

EXTRA: I can get the time with javascript in my index just fine. I also found this cute thing: https://fengari.io/ that allows me run lua/javascript very easily. BUT I couldn't figure a way of making the gate between my game and the index page scripts, making them interact and trigger events from my game. I don't even know if this is possible, but would be cool because I could then use https://docs.kongregate.com/docs/javascript-api as well!

Re: How do I do simple http requests with love/lua?

Posted: Tue Feb 11, 2020 2:40 pm
by zorg
Yeah, this seems more of a lovejs issue than löve, especially since you yourself said that it worked in löve proper.