I am new to Playwright and js so I'm a bit lost here. I want to be able to send a request and then check status, content of response, headers, etc.
I thought I would be able to do something like
  test('blah', async ({ request }) => {
    await request.get('http://localhost:444').then(res => {
      expect(res.status()).toBe(200)
      expect(res.headers()['content-type']).toBe('application/octet-stream')
      expect(res.json()).toContain('foo')
    })
  })
but this doesn't work and the expect sees res.json() as "{}" and if I try to print the response to console with console.log(res.json()) I get back Promise { <pending> }
I eventually got my test working properly by using the below code but it seems messy to me and I dont know why I have to do this? am I doing this correctly? or am I way off?
test('blah', async ({ request }) => {
    await request.get('http://localhost:4444/')
      .then(res => {
        expect(res.status()).toBe(200)
        return res.json()
      })
      .then(json => {
        expect(JSON.stringify(json)).toContain('foo')
      })
  })
 
     
    