Object Notation

Options
I'm trying to get the value for a property of an item in a Webflow CMS Collection.

This is the JSON

[CleanShot 2021-06-27 at 01.09.41@2x.png]

Ho would I access created-on?  
I first did a foreach on myvar.response.result.items as item
then I tried to access it via:

1) item.created-on
2) item["created-on"] 

and I still couldn't get it.  

Tried looking at the documentation and couldn't find the answer.

Thanks!

Joe

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Hey Joe - I'd use the SUBPATH feature to get as exact as possible, run the API, copy the results as JSON, create a new variable - hover over the variable name of the API call and click SUBPATH next to it. Then paste in the results and click define - this will allow you to click the exact field you want... item is in results so you at least need results.item.created-on - however, this is also an array so if you want a specific index you should specify that (i.e. results.item.0.created-on) however, I can't see your full response so my recommendation is the subpath method. 
  • Joe Thong
    Joe Thong Member
    Options
    Hey Michael Thanks!  I will look into subpath
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    There's a few videos of it in action (external APIs) but I'll make sure to include a tutorial specifically for it too soon
  • gstaproton
    Options
     If I were to use the method above could I get all items in similar subpaths like "results.item.0.created-on, results.item.1.created-on, results.item.3.created-on" ETC? After creating the variable and selecting subpath, I'm only able to return the results from one entry. The API I'm using outputs its responses similar to those in this thread. So I only end up getting the first it the array with the above field. Basically only results.item.0.created-on and not results.item.0.created-on and not results.item.x.created-on like I want. I want to be able to apply the tutorial in your video below to an API like the one in this thread.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     if you remove the index from your dot notation Xano will transform the data into a list of that path (Example: results.item.created-on)
  • gstaproton
    Options
     Thank you for the quick reply. I really appreciate itThat did it. Now I'm I'm trying to find out the best way to get new data into hubspot from Xano.