javascript node.js puppeteer webautomation

How to get body / json response from XHR request with Puppeteer

I want to get the JSON data from a website I’m scraping with Puppeteer, but I can’t figure how to get the body of the request back. Here’s what I’ve tried:

const puppeteer = require('puppeteer')
const results = [];
(async () => {
const browser = await puppeteer.launch({
headless: false
const page = await browser.newPage()
await page.goto("", {
waitUntil: 'networkidle2'
await page.type('#search-form > input[type="text"]', 'bd14ew')
await'#search-form > input[type="submit"]')
await page.on('response', response => {
if (response.url() == ""){
console.log('XHR response received');

This just returns a promise pending function. Any help would be great.

As response.json returns a promise we need to await it.

page.on('response', async (response) => {    
if (response.url() == ""){
console.log('XHR response received');
console.log(await response.json());