Setting a nunjucks variable from a nested object

447 Views Asked by At

I apologise for the long console log, but I need it for my question. I'm trying to set the value of 'intro' (thwelth from the bottom) to a nunjucks variable, just don't seem to be able to use the correct syntax. The log is as follow (from airtables API): I use a function to call the data which is returned as a named object 'applications' so I am trying something like

{% set intro =  applications[0].fields.intro %} 

but that ain't working. Thanks in advance

[
      Record {
        _table: Table {
          _base: [Base],
          id: null,
          name: 'applications',
          find: [Function],
          select: [Function: bound ],
          create: [Function],
          update: [Function],
          replace: [Function],
          destroy: [Function],
          list: [Function],
          forEach: [Function]
        },
        id: 'rec7FuJxke2mL104B',
        _rawJson: {
          id: 'rec7FuJxke2mL104B',
          fields: {},
          createdTime: '2020-10-14T15:02:53.000Z'
        },
        fields: {},
        save: [Function],
        patchUpdate: [Function],
        putUpdate: [Function],
        destroy: [Function],
        fetch: [Function],
        updateFields: [Function],
        replaceFields: [Function]
      },
      Record {
        _table: Table {
          _base: [Base],
          id: null,
          name: 'applications',
          find: [Function],
          select: [Function: bound ],
          create: [Function],
          update: [Function],
          replace: [Function],
          destroy: [Function],
          list: [Function],
          forEach: [Function]
        },
        id: 'recJWqHcYUx0Q9Cih',
        _rawJson: {
          id: 'recJWqHcYUx0Q9Cih',
          fields: [Object],
          createdTime: '2020-10-13T22:37:03.000Z'
        },
        fields: {
          Post: 'https://www.yokoco.com/career/digital-designer-art-director/',
          intro: "As well as super-hero mind powers, my last role involved collaborating with Cafédirect, the UK's first 'B' corp certified coffee company, investing 50% of their profits into Producers Direct. As Big Al's head of art, alongside a copywriter, I completed typographic treatments and illustration styles for Cafédirects up and coming poster and social campaign, Hooray for poverty-free coffee!\n",
          Job: 'Digital Designer / Art Director',
          Sent: '2020-10-13',
          Status: 'In progress'
        },
        save: [Function],
        patchUpdate: [Function],
        putUpdate: [Function],
        destroy: [Function],
        fetch: [Function],
        updateFields: [Function],
        replaceFields: [Function]
      }
    ]
0

There are 0 best solutions below