Registry / testing / ava-http

ava-http

JSON →
library1.0.0jsnpmunverified

AVA-http is a lightweight async HTTP request wrapper built on top of Request-Promise, designed originally for AVA test runners but usable anywhere. Version 1.0.0 targets Node >=4 with ESM support. It provides simplified GET, POST, PUT, DELETE methods that return only the response body on success, with companion *Response variants that always return the full response object. Compared to raw request-promise, it reduces boilerplate by defaulting to JSON parsing and providing a cleaner API for quick HTTP assertions.

npm install ava-http
INSTALL
IMPORT
SIG · AVA-HTTP
A
ava-http
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

http
import http from 'ava-http'
import { http } from 'ava-http'
Default export is an object with methods. Named import will not work.
getResponse
const { getResponse } = require('ava-http')
import { getResponse } from 'ava-http'
For CommonJS, destructure from default export. ESM default import works, but named import may fail if package does not export named members.

Demonstrates basic GET and POST requests using ava-http inside an AVA test file.

import test from 'ava'; import http from 'ava-http'; const url = 'https://jsonplaceholder.typicode.com/posts/1'; test('async get request', async t => { const body = await http.get(url); t.truthy(body); t.true(typeof body === 'object'); t.is(body.id, 1); }); test('post with JSON body', async t => { const options = { body: { userId: 1, title: 'foo' }, json: true }; const payload = await http.post(url.replace('/1', ''), options); t.truthy(payload.id); });
Debug
Known issues
gotchaError responses return the full Response object, not the body. Always use .catch() or try/catch to handle non-2xx status codes.
fix
Wrap calls in try/catch and inspect response properties (statusCode, body) on failure.
affects: *
gotchaIf you need the full Response object on success (e.g., to check statusCode), use http.getResponse instead of http.get.
fix
Use the *Response variants: http.getResponse, http.postResponse, etc.
affects: *
deprecatedRequest-Promise (underlying library) has been deprecated; consider migrating to a modern HTTP client like got or undici.
fix
Switch to got or node-fetch with equivalent APIs.
affects: *
gotchaThe `form` option automatically sets content-type header; do not set it manually or you may get duplicate headers.
fix
Either use `form` and let the library set headers, or set headers manually and omit `form`.
affects: *
Errors
Common errors & fixes
Cannot find module 'ava-http'
Package not installed or installed as devDependency but used in production.
fix
Run `npm install --save-dev ava-http` (or `--save` for production) and ensure node_modules is correct.
TypeError: http.get is not a function
Named import instead of default import.
fix
Use `import http from 'ava-http'` not `import { http } from 'ava-http'`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
request-promiserequiredCore HTTP request functionality delegated to request-promise
Agent activity
25 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
ava-http — npm install ava-http · libregistry