title: Intercept a certain request and get its response (puppeteer)
body: <p>Once that puppeteer goes to a certain url, I want that it listens to all the requests that are made, then find a specific request and return its response. The response should be a json object.</p>
  
  <p>I managed in listening to all the requests and intercepting the desired one, but I don't know how to get its response. Here's my attempt: I get the error <code>TypeError: Cannot read property 'then' of null</code>.</p>
  
  <p>Any suggestion? </p>
  
  <pre><code>page.on('request',async(request)=&gt;{
      console.log(request.url())
  
      if (request.url().includes('desiredrequest.json')){
          console.log('Request Intercepted')
          request.response().then(response =&gt; {
              return response.text();
          }).then(function(data) {
          console.log(data); // this will be a string
          alert(data)
          });
      }
  
      request.continue()
  })
  </code></pre>