Accessing a JSON element

I pull my document array and access it with this
var docs = this.doc[this.ticker_symbol]

console.log(docs)

returns

[
  {
    siteId: 'aaauetf',
    name: 'Fact Sheet',
    docOrder: '0',
    docType: ' Factsheet',
    ticker: 'aaau',
    _id: '5cf93d4e5e2d5445b647e63a',
    createdAt: '2019-06-06T16:20:30.765Z',
    updatedAt: '2020-01-10T21:29:32.311Z',
    __v: 0,
    id: '5cf93d4e5e2d5445b647e63a',
    doc: {
      _id: '5e18ecbc893fe012540eea36',
      name: 'AAAU Fact Sheet Q4 v1-APPROVED.pdf',
      sha256: 'x72zbL2nblED4A4RjAEvGz-i7D4Dh8xaKYKhhwcP7sk',
      hash: '9bd1480c74a44a4ebe4415a80e023137',
      ext: '.pdf',
      mime: 'application/pdf',
      size: '155.07',
      url: '/uploads/9bd1480c74a44a4ebe4415a80e023137.pdf',
      provider: 'local',
      related: [Array],
      createdAt: '2020-01-10T21:29:32.330Z',
      updatedAt: '2020-01-10T21:29:32.333Z',
      __v: 0,
      id: '5e18ecbc893fe012540eea36'
    },
    doc_thumb: null
  },
  {
    siteId: 'aaauetf',
    name: 'Investment Case',
    docOrder: '1',
    docType: ' Other',
    ticker: 'aaau',
    _id: '5cf93d6d5e2d5445b647e63d',
    createdAt: '2019-06-06T16:21:01.356Z',
    updatedAt: '2019-07-12T16:27:58.371Z',
    __v: 0,
    id: '5cf93d6d5e2d5445b647e63d',
    doc: {
      _id: '5d28b50ee13db21120e6c487',
      name: 'AAAU Investment Case_8 July 2019 V4 Reformatted Final Approved.pdf',
      sha256: '4GLG1CfmE625x23iMEXAxEx6GCQvkvGXubObJyjk9QE',
      hash: '621aacd6227a4b3ea7b173fe3f555726',
      ext: '.pdf',
      mime: 'application/pdf',
      size: '169.36',
      url: '/uploads/621aacd6227a4b3ea7b173fe3f555726.pdf',
      provider: 'local',
      related: [Array],
      createdAt: '2019-07-12T16:27:58.385Z',
      updatedAt: '2019-07-12T16:27:58.386Z',
      __v: 0,
      id: '5d28b50ee13db21120e6c487'
    },
    doc_thumb: null
  },
  {
    siteId: 'aaauetf',
    name: 'White Paper',
    docOrder: '1',
    docType: ' Other',
    ticker: 'aaau',
    _id: '5d8bb23d2c14ca03d6f4d29e',
    createdAt: '2019-09-25T18:30:21.969Z',
    updatedAt: '2019-09-25T18:30:21.981Z',
    __v: 0,
    id: '5d8bb23d2c14ca03d6f4d29e',
    doc: {
      _id: '5d8bb23d2c14ca03d6f4d29f',
      name: 'AAAU white paper v7 formatted 9.24.19-APPROVED.pdf',
      sha256: 'D8MlsyLNn0z4pJryOMzrfLwZsOK2jGPKqmwiXJi2HI8',
      hash: 'cde846ad152f42ae8ac16f45650c59d7',
      ext: '.pdf',
      mime: 'application/pdf',
      size: '455.16',
      url: '/uploads/cde846ad152f42ae8ac16f45650c59d7.pdf',
      provider: 'local',
      related: [Array],
      createdAt: '2019-09-25T18:30:21.990Z',
      updatedAt: '2019-09-25T18:30:21.992Z',
      __v: 0,
      id: '5d8bb23d2c14ca03d6f4d29f'
    },
    doc_thumb: null
  }
]

I want to grab all objects that are docType: ’ Other’

Is there a way to access this? Do I need to loop?

var docs  = this.doc[this.ticker_symbol]
var other = docs.docType[' Other'];

doesn’t work

docs.filter((x) => x.docType == ' Other');

2 Likes