Home > Mobile >  How do I get total number of columns received in RestAPI response?
How do I get total number of columns received in RestAPI response?

Time:02-12

Example Response From RestAPI

This Is How My Current Parameter Input Looks Like:

value={data?.body?.marketState}

I want to return no. of columns in "marketState".

eg.

4

CodePudding user response:

You can simply access the .length property on the array

value={data?.body?.marketState?.length}

For more info about .length:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length

For more information about JavaScript arrays in general:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

  • Related