Skip to content

http2 demo not working as expected #2257

@mcollina

Description

@mcollina

Consider the following:

import { request, fetch, Agent, Client, setGlobalDispatcher } from './index.js'

setGlobalDispatcher(new Agent({
  allowH2: true
}))

// Not working as expected
// the request is done using HTTP/1.1
const res1 = await fetch(`https://http2.pro/api/v1`)
console.log(await res1.json())

// Not working as expected, the response is never received
const client = new Client('https://http2.pro', {
  allowH2: true
})

const res2 = await request(`https://http2.pro/api/v1`, { dispatcher: client })
console.log(await res2.body.json())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions