Fetch API: TypeError: Cannot read properties of null (reading ‘getReader’) [duplicate]

I am trying to use fetch API as:

fetch(".../data", {mode: 'no-cors'})
  // Retrieve its body as ReadableStream
  .then((response) => {
    const reader = response.body.getReader();
    // read() returns a promise that resolves when a value has been received
    reader.read().then(function pump({ done, value }) {
      if (done) {
        // Do something with last chunk of data then exit reader
        return;
      }
      // Otherwise do something here to process current chunk
      console.log(value);

      // Read some more, and call this function again
      return reader.read().then(pump);
    });
  })
  .catch((err) => console.error(err));

When I hit url in browser, results are fetched.

But with above code, I see error:

TypeError: Cannot read properties of null (reading 'getReader')

What am I missing here?