Hi.
Actually, I write a code that works but I think is not correct.
I make a network.request and in the event handler I put in options params the response data that I pass on another Scene.
Since from that Scene I have to made two network.request I want to call them on the proper button touch handler, but if I do that no data is passed.
local function handleGolfClubResponse( event ) if not event.isError then local response = json.decode( event.response ) if response.status == “OK” then h = #response.data for i=1,h do table.insert(options.params, {nome = response.data[i].nome, descrizione = response.data[i].descrizione, immagine = response.data[i].immagine, data_fine = response.data[i].data_fine, data_validita = response.data[i].validita, prezzo= response.data[i].prezzo, listino = response.data[i].listino }) end end else print( “Error!” ) end return end
network.request( “http://codelessfuture9892.cloudapp.net/api/itinerari”, “GET”, handleItinerariResponse, {} )
local function onObjectTouch( event )
if ( event.phase == “ended”) then
if ( event.target.id == “Bundle”) then
changeTabBar()
– if I put network.request here, in bundle.lua I got error
composer.gotoScene( “bundle”, options ) – NOW IS OK
elseif ( event.target.id == “Club”) then
changeTabBar()
composer.gotoScene( “club”, options )
elseif ( event.target.id == “Search”) then
print( “Search” )
end
return true
end
end