Skip to content

Getting the body from a Got stream #1612

@Richienb

Description

@Richienb

What would you like to discuss?

After creating a got stream like so:

const got = require("got")

const requestStream = got.stream("https://google.com")

I found that to get the result buffer this needs to be done:

const pEvent = require("p-event")
const getStream = require("get-stream")

const [result] = await Promise.all([getStream.buffer(requestStream), pEvent(requestStream, "response")])

Is there a simpler way to do this?

Checklist

  • I have read the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions