openblocks-dev / openblocks

🔥 🔥 🔥 The Open Source Retool Alternative
https://cloud.openblocks.dev
GNU Affero General Public License v3.0
5.77k stars 346 forks source link

Accept String for Total Row Count #224

Open gboxxx opened 1 year ago

gboxxx commented 1 year ago

I'm trying to supply a total row count from the Woocommerce API. It provides this, along with total pages, in the headers. I'm getting NaN -> 0. I'm guessing because the header is returning a string?

lmx1117 commented 1 year ago

Can you provide a screenshot of the query for us, including which Woocommerce API you are using and what is the return value

gboxxx commented 1 year ago

Woocommerce API V3 using {{get_products.extra.headers.X-WP-Total}}.

CleanShot 2023-01-31 at 09 06 32

Here's an example response copied directly from Openblocks Total Row Count section (X-WP-Total removed to produce):

{"Connection":["keep-alive"],"Content-Type":["application/json; charset=UTF-8"],"X-Robots-Tag":["noindex"],"X-Content-Type-Options":["nosniff"],"Access-Control-Expose-Headers":["X-WP-Total, X-WP-TotalPages, Link"],"Access-Control-Allow-Headers":["Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type"],"Cache-Control":["no-cache, must-revalidate, max-age=0"],"X-QM-overview-time_taken":["2.6683"],"X-QM-overview-time_usage":["1.5% of 178s limit"],"X-QM-overview-memory":["159,583 kB"],"X-QM-overview-memory_usage":["51.9% of 307,200 kB limit"],"X-WP-Total":["740"],"X-WP-TotalPages":["30"],"Link":["<https://mydomain.com/wp-json/wc/v3/products?search&per_page=25&page=2>; rel=\"next\""],"Allow":["GET, POST"],"X-XSS-Protection":["1"],"Referrer-Policy":["no-referrer-when-downgrade"],"X-FW-Server":["Flywheel/5.1.0"],"X-FW-Dynamic":["TRUE"],"X-FW-Hash":["stg_da4e4ee7nv"],"X-FW-Version":["5.0.0"],"Server":["Flywheel/5.1.0"],"X-Cacheable":["NO:Not Cacheable"],"Fastly-Restarts":["1"],"Accept-Ranges":["bytes"],"Date":["Tue, 31 Jan 2023 15:08:40 GMT"],"X-Served-By":["cache-pdk17842-PDK"],"X-Cache":["MISS"],"X-Cache-Hits":["0"],"X-Timer":["S1675177717.348947,VS0,VE2890"],"Vary":["Accept-Encoding"],"X-FW-Serve":["TRUE"],"X-FW-Static":["YES"],"X-FW-Type":["FLYWHEEL_BOT"],"content-length":["66729"]} → 0

Esieve commented 1 year ago

It seems like the type of X-WP-Total is array.So you can try to reference it like this:

{{get_products.extra.headers.X-WP-Total[0]}}

gboxxx commented 1 year ago

Tried that too.

image

Esieve commented 1 year ago

I'm sorry that was my fault! Please try this:

{{get_products.extra.headers['X-WP-Total'][0]}}

gboxxx commented 1 year ago

That did the trick! May be worth noting that Handlebar statement worked in both Appsmith & Retool.

I'm not a developer, but still learning all the various ways to access data via Handlebars and dot notation (learned about currentRow.blahblah [0]?.bleh the other day). Thanks for the help!

YoJayz commented 1 year ago

Hi @gboxxx, this issue has been fixed in Openblocks v1.1.6. Now you can use dot notations to access properties named with hyphens(-) successfully. Please check it out!

Thanks for your support and patience. For more release notes, see Openblocks releases.

gboxxx commented 1 year ago

Hi @gboxxx, this issue has been fixed in Openblocks v1.1.6. Now you can use dot notations to access properties named with hyphens(-) successfully. Please check it out!

Awesome, thanks for tagging me!