tessl install tessl/npm-xmlhttprequest@1.8.0XMLHttpRequest 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%
Build a small client module that performs asynchronous HTTP requests for common CRUD-style actions against a JSON resource endpoint and exposes parsed responses.
/items/42 resolves asynchronously using the configured base URL and returns the parsed JSON body with status 200. @test/items/42 completes without a body, sends caller-provided headers, and returns the response headers. @test/items sends the provided JSON payload and resolves with the created representation and status 201. @test/items/42 sends the provided JSON payload and returns the updated representation and status 200. @test/items/42 completes asynchronously with status 204 and an empty body. @test@generates
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;Provides a browser-style HTTP request interface for Node.js.