CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-xmlhttprequest

tessl install tessl/npm-xmlhttprequest@1.8.0

XMLHttpRequest for Node.js that emulates the browser XMLHttpRequest object

Agent Success

Agent success rate when using this tile

75%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.15x

Baseline

Agent success rate without this tile

65%

task.mdevals/scenario-8/

Async Resource Client

Build a small client module that performs asynchronous HTTP requests for common CRUD-style actions against a JSON resource endpoint and exposes parsed responses.

Capabilities

Base URL and async lifecycle

  • A GET to /items/42 resolves asynchronously using the configured base URL and returns the parsed JSON body with status 200. @test
  • A HEAD to /items/42 completes without a body, sends caller-provided headers, and returns the response headers. @test

Writing data

  • A POST to /items sends the provided JSON payload and resolves with the created representation and status 201. @test
  • A PUT to /items/42 sends the provided JSON payload and returns the updated representation and status 200. @test

Deletion

  • A DELETE to /items/42 completes asynchronously with status 204 and an empty body. @test

Implementation

@generates

API

export type HttpHeaders = Record<string, string>;

export type HttpResult = {
  status: number;
  body?: any;
  headers: HttpHeaders;
};

export interface ResourceClient {
  get(path: string, headers?: HttpHeaders): Promise<HttpResult>;
  post(path: string, data: any, headers?: HttpHeaders): Promise<HttpResult>;
  put(path: string, data: any, headers?: HttpHeaders): Promise<HttpResult>;
  remove(path: string, headers?: HttpHeaders): Promise<HttpResult>;
  head(path: string, headers?: HttpHeaders): Promise<HttpResult>;
}

export function createResourceClient(baseUrl: string, defaultHeaders?: HttpHeaders): ResourceClient;

Dependencies { .dependencies }

xmlhttprequest { .dependency }

Provides a browser-style HTTP request interface for Node.js.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/xmlhttprequest@1.8.x
tile.json