XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object
Overall
score
75%
Build a helper that issues an HTTP request and progressively reports incoming text chunks while also exposing the final status code and status message provided by the server.
status: 200, statusText: "OK READY", and a body containing the full response text. @teststatus: 503, preserves the status message from the server, and returns a body of "busy" even though the response indicates failure. @test@generates
/**
* Performs an HTTP request that streams text chunks to an optional handler and resolves when the response finishes.
*
* @param {Object} options
* @param {string} options.url - Target URL to request.
* @param {string} [options.method="GET"] - HTTP method to use; must support GET and HEAD at minimum.
* @param {(chunk: string) => void} [options.onChunk] - Invoked immediately for each incoming text fragment, in order.
* @returns {Promise<{ status: number, statusText: string, body: string }>} Resolves with final status details and concatenated body.
*/
export async function fetchWithStreaming(options);Provides an HTTP client capable of streaming response text and exposing status information.
Install with Tessl CLI
npx tessl i tessl/npm-xmlhttprequestdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10