Looping the HttpClient Response object


Ryan Sytsma
I have call to my ASP.NET Web API that returns a json file with 2 records in it. I take the response, create a new array as Report2.Data and ArrayPush each row. However, the 2nd row of the array is the only row that gets pushed to the Report2.Data array and shows 2 times. The first record does not get added to the array. Thoughts?

Ryan Sytsma
Here is my Report2 html

DecSoft

Hello Ryan,

It's difficult to say, after take a look at your code, which appear fine, that is, I can't see right now anything rare or wrong, so, that code must work as expected. You must debug what happen, Ryan, for example, take a look at the browser's console (use Firefox, Chrome or other browser) for the HTTP Client response: look if that is what you expect, and, also look if some possible error occur (and it's placed in the browser's console).

P.S. If you want to provide an app which can reproduce the problem, please, don't hesitate to send me the app at info@decsoftutils.com



Ryan Sytsma
This is the json string I get: My report control displays the 2nd record twice but not the first record. In Chrome debugger, I get this But, this error is BEFORE I execute the HttpClient

DecSoft

Hello Ryan,

Before go ahead, and, since the server's response is an Array of objects, please, try to directly assign the server's response to the report's data variable: in other words, probably you no need to iterate over the server's response, just assign the server's response to the report's data variable. You can use the "CopyVar" or the "ArrayConcat" actions, for example.



Ryan Sytsma
So, would I take the HttpClient Response object and just assign that directly to the Report.Data ?

DecSoft

Hello Ryan,

Yes; not only you can... in fact, is the preferred way: the server's response can be (always that is possible) an Array of objects, that is, something that we can directly assign to the Report.Data variable.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.