Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:54:09+00:00 2026-05-28T05:54:09+00:00

I’m new to Corona SDK and Lua language and I have some troubles.. so

  • 0

I’m new to Corona SDK and Lua language and I have some troubles..

so I have this function which sends network request to my site and through json I receive the data. This works great.

The problem is that when I call the variable with the data response outside the listener function, it seems to be nil. I put a small timer to track if the issue was because of the time between the request and response and it seems to be that one (but I’m not sure 100%). I don’t want to use custom delay to perform this operation.

Is there some way to pause the script until the listener response and then continue execution? I have tried with coroutines but I couldn’t solve it..

local data

function networkListener( event )
    if ( event.isError ) then
        print( "Network error!")
    else
    --print ( "RESPONSE: " .. event.response )

        data = json.decode(event.response)

        print( data[1].start_date ) --working great

    end -- end of else statement
end


network.request( "http://localhost/mysite/myphpmethod" , "GET", networkListener )

print(data) -- error: attempt to index upvalue 'data' ( a nil value ) 

local function printIt()
    print( data[1].start_date)
end

timer.performWithDelay(1000, printIt, 1); -- this works 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:54:09+00:00Added an answer on May 28, 2026 at 5:54 am

    The HTTP call is asynchronous, which means indeed that your print(data) will almost always be empty, even the performWithDelay might be empty on a bad day.

    You will have to design your app in such a way that the game code continues within networkListener() ( in this particular case you would call printIt() from networkListener().

    This takes some thinking and re-designing but it is not that bad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.