I’m trying to use network.request for my app. The example app works fine. However, when I modify it to pass the data to a variable, instead of just printing the data, the value is set to nil.
Original example from anscamobile.com (Works ok, but only prints the data without passing it along):
local function networkListener( event )
if ( event.isError ) then
print( "Network error!")
else
print ( "RESPONSE: " .. event.response )
end
end
-- Access Google over SSL:
network.request( "https://encrypted.google.com", "GET", networkListener )
what I’m trying to do (notice the new variable ‘response’, to which i’m trying to pass the data to):
local response;
local function networkListener( event )
if ( event.isError ) then
print( "Network error!")
else
response = "RESPONSE: " .. event.response
end
end
-- Access Google over SSL:
network.request( "https://encrypted.google.com", "GET", networkListener )
print (response);
(‘response’ returns NIL instead of the data.) [import]uid: 33608 topic_id: 16243 reply_id: 316243[/import]
[import]uid: 3826 topic_id: 16243 reply_id: 60515[/import]