Getting fetch response in lua
DoubleShotgun opened this issue · comments
DoubleShotgun commented
I want to do this:
fetch(url)
.then(response => response.json()).then(json => {
console.log(json)
})
But in lua.
I tried this:
local promise = window:fetch(url)
promise["then"](promise, function() --[[get response?]] end)
But I have no idea how to get the response.
Benoit Giannangeli commented
Just add the argument to the callback function signature.
DoubleShotgun commented
Like this?
promise["then"](promise, function(response) print(response) end)
if so, it is just given me a nil.
Btw the link I'm using does work.
Benoit Giannangeli commented
Yes the first argument is this
which is null in this context. Add a second one