Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Connection failure NETWORK REQUEST
Started by diego_martinez93 Mar 15 2019 07:52 PM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

diego_martinez93

[GLOBAL: userInfoPane.html]
diego_martinez93
  • Observer

  • 9 posts
  • Corona SDK

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

 



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,373 posts
  • Enterprise

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




[topic_controls]
[/topic_controls]