Making API calls with node-fetch in nodejs issue

Hi all, I have some code where I’m using node-fetch to make an API call to the graph that looks like this:

import fetch from "node-fetch"

const url = "https://api.studio.thegraph.com/query/XXXXXX"
const query = `
{
    itemListedEntities(first: 5) {
      id
      seller
      nftAddress
      tokenId
    }
  }
`

async function main() {
    const response = await fetch(url, {
        method: "POST",
        Header: {
            "Content-Type": "application/graphql",
        },
        body: query,
    })
    console.log(response)
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error)
        process.exit(1)
    })

In a file called runGraph.mjs, and I’m running it with node runGraph.mjs

I’m wondering:

  1. Is this the best way to call the graph in nodejs?

I know apollo is shown in the docs, but I’m looking to call from node

  1. I seem to be getting an error…

In my playground, I get a response that looks like this:

{
  "data": {
    "itemListedEntities": [
      {
        "id": "0x643315c9be056cdea171f4e7b2222a4ddab9f88d",
        "seller": "0x643315c9be056cdea171f4e7b2222a4ddab9f88d",
        "nftAddress": "0xa418790a4945676773f39100995724227c95268f",
        "tokenId": "0"
      }
    ]
  }
}

However, my API response is:

Response {
  size: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kTransformState)]: [Object]
    },
    stream: PassThrough {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      [Symbol(kCapture)]: false,
      [Symbol(kTransformState)]: [Object]
    },
    boundary: null,
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    type: 'default',
    url: 'https://api.studio.thegraph.com/query/XXXXX',
    status: 400,
    statusText: 'Bad Request',
    headers: {
/* some header stuff here */
    },
    counter: 0,
    highWaterMark: 16384
  }
}

I’m assuming I’m doing something wrong here, but not sure what.