HTTP Request - Completed Event
Fired when the HTTP request returns after processing successfully
Member of HTTP Request (PRIM_WEB.HttpRequest)
Details
The Completed event is fired when the request completes successfully.
Event routines are best coded within the method that the requested is executed in.
Example
In this example, a weather API is executed asynchronously, returning the data as a JSON object.
When the completed event fires, the result is processed.
Mthroutine Name(GetWeather) Access(*Private)
Define_Map For(*Input) Class(#prim_alph) Name(#Resource)
Define_Com Class(#PRIM_WEB.HttpRequest) Name(#Request)
#Request.URL := "http://api.openweathermap.org" + #Resource
#Request.ExecuteAsync
Evtroutine Handling(#Request.Completed)
If (#Request.Response *IsNot *null)
Case (#Request.Response.Status)
When (= 200)
#Com_owner.Update( #Request.Response.JSON.RootItem )
Otherwise
#Com_owner.UpdateForFailure( #Request )
Endcase
Endif
Endroutine
Endroutine