0

I've been tasked with a project that requires the use of API. I would love to learn if possible, how to delve into an object using node-fetch API.

I am looking to fetch a list of objects on a page, I am currently able to receive information as to where the data is stored, however it's left me questioning whether it would be possible.

I have fetched from the url as required, input all options I would need to access said data.

const response = await fetch("https://alt-platform-server.production.internal.onlyalt.com/graphql/MultiPartItemGroupsComplete", {

I ensured that the body and method were setup correctly.

        "body": "{\"operationName\":\"MultiPartItemGroupsComplete\",\"variables\":{\"input\":{\"cursor\":null,\"limit\":100}},\"query\":\"query MultiPartItemGroupsComplete($input: ItemGroupsInput!) {\\n  itemGroups(input: $input) {\\n    itemGroups {\\n      items {\\n        ...MultiPartItemInitial\\n        ...MultiPartItemDetails\\n        __typename\\n      }\\n      __typename\\n    }\\n    cursor\\n    totalCount\\n    __typename\\n  }\\n}\\n\\nfragment MultiPartItemInitial on Item {\\n  id\\n  displayNames {\\n    ...ItemDisplayNamesBase\\n    __typename\\n  }\\n  images {\\n    ...ImageBase\\n    __typename\\n  }\\n  __typename\\n}\\n\\nfragment ItemDisplayNamesBase on ItemDisplayNames {\\n  itemName\\n  groupName\\n  assetName\\n  __typename\\n}\\n\\nfragment ImageBase on Image {\\n  position\\n  url\\n  __typename\\n}\\n\\nfragment MultiPartItemDetails on Item {\\n  id\\n  purchaseDate\\n  timeSeriesStats {\\n    ...PortfolioTimeSeriesStatsBase\\n    __typename\\n  }\\n  attributes {\\n    ...ItemAttributesBase\\n    __typename\\n  }\\n  itemVaultState {\\n    ...ItemVaultStateBase\\n    __typename\\n  }\\n  listing {\\n    ...ItemListingBase\\n    __typename\\n  }\\n  __typename\\n}\\n\\nfragment PortfolioTimeSeriesStatsBase on TimeSeriesStats {\\n  latestValue\\n  costBasis\\n  changeOverWeek\\n  changeOverWeekPercent\\n  unrealizedGain\\n  unrealizedGainPercent\\n  __typename\\n}\\n\\nfragment ItemAttributesBase on ItemAttributes {\\n  gradeNumber\\n  gradingCompany\\n  serial\\n  printRun\\n  certNumber\\n  autograph\\n  centering\\n  corners\\n  edges\\n  surfaces\\n  qualifier\\n  __typename\\n}\\n\\nfragment ItemVaultStateBase on ItemVaultState {\\n  createdAt\\n  state\\n  __typename\\n}\\n\\nfragment ItemListingBase on Listing {\\n  id\\n  state\\n  listPrice\\n  type\\n  __typename\\n}\\n\"}",
        "method": "POST"

But when I output I receive:

{
  data: {
    itemGroups: {
      itemGroups: [Array],
      cursor: '1668524928.869299:a735305e-eec9-4ae5-a7ef-04acc3d36023',
      totalCount: 3283,
      __typename: 'ItemGroupsPayload'
    }
  }
}

I am looking to get into the [Array], however can't see how it would be possible.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Dan
  • 1
  • This is just `console.log` trying to not flood your terminal. The data is still there. – Bergi Nov 16 '22 at 18:50
  • "But when I output"... How do you "output"? If all you want to do is inspect the data you receive from the API, I would use a "JSON viewer" type application, like [this one](http://jsonviewer.stack.hu/) Or use `console.log(JSON.stringify(object, null, 2))` for a text-based view of the data. – Heretic Monkey Nov 16 '22 at 18:52

0 Answers0