Connection failure NETWORK REQUEST

Hi. i have this error when i try get data from the server. Can you help me?. tanks

function db.download_users()

    local URL = IP…"/app1Api/User"

    local function networkListener( event )

        if (event.isError) then

         print(event.response)

        else

            local decodedData = json.decode(event.response)

            if(decodedData.error ~= nil) then

            else

                for k,v in pairs(decodedData) do

                    

                end

            end

        end

    end

    network.request(URL, “GET”,networkListener)

end

What is the variable IP?

What is the value of event.isError?

What is the value of event.response?

Is there an error member of your expected JSON in decodedData?

Honestly, you can learn a lot more by making this simple change:

function db.download\_users() local URL = IP.."/app1Api/User" local function networkListener( event ) print( json.prettify( event ) ) if (event.isError) then print(event.response) else local decodedData = json.decode(event.response) if(decodedData.error ~= nil) then else for k,v in pairs(decodedData) do end end end end network.request(URL, "GET",networkListener) end

Dumping the whole event table will tell you a lot. Is the URL timing out or bad? Is the web server on the other end working but giving you a 404 error because the page doesn’t exist? Help us with that information so we can help you…

Rob

What is the variable IP?

What is the value of event.isError?

What is the value of event.response?

Is there an error member of your expected JSON in decodedData?

Honestly, you can learn a lot more by making this simple change:

function db.download\_users() local URL = IP.."/app1Api/User" local function networkListener( event ) print( json.prettify( event ) ) if (event.isError) then print(event.response) else local decodedData = json.decode(event.response) if(decodedData.error ~= nil) then else for k,v in pairs(decodedData) do end end end end network.request(URL, "GET",networkListener) end

Dumping the whole event table will tell you a lot. Is the URL timing out or bad? Is the web server on the other end working but giving you a 404 error because the page doesn’t exist? Help us with that information so we can help you…

Rob