Registry / http-networking / cogent

cogent

JSON →
library1.9jsnpmunverified

Cogent is a simple HTTP request library built for Node.js and generators using co. It supports redirect resolution, timeout, automatic gunzip decompression, and first-class JSON parsing. The response can be buffered, saved to a file, or returned as parsed JSON. Options include retries, timeouts, and customizable request properties. Version 1.0.1 is stable but the package is part of the cojs ecosystem and has seen no recent updates. It relies on generators and the co library, making it less suitable for modern async/await workflows without additional wrapping.

npm install cogent
INSTALL
IMPORT
SIG · COGENT
C
cogent
http-networkingjavascriptv1.9
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

request
✓ import request from 'cogent'
Default import; the module exports a generator function directly.
request
✓ const request = require('cogent')
✗ const { request } = require('cogent')
CommonJS requires the default export, not a named property.
extend
✓ import { extend } from 'cogent'
✗ import extend from 'cogent/extend'
Named export for creating a new instance with default options.

Demonstrates fetching a JSON endpoint using a generator function, parsing JSON response, and logging the body.

const co = require('co'); const request = require('cogent'); co(function* () { const res = yield* request('https://api.github.com/repos/visionmedia/express/package.json', { json: true }); console.log(res.body); }).catch(err => console.error(err));
Debug
Known issues
deprecatedGenerator-based APIs are outdated; prefer async/await with modern HTTP libraries like node-fetch or axios.
fix
Use async/await with a library that returns promises (e.g., node-fetch).
affects: >=1.0.0
gotchaWhen using 'cogent' without co, the generator must be yielded manually.
fix
Wrap with co: const wrapped = co(require('cogent'));
affects: >=1.0.0
gotchaThe 'json' option only populates res.body on a 200 status code; non-200 responses will not have a parsed body.
fix
Check res.statusCode before accessing res.body.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: request(...) is not a function
Attempting to call the generator without using yield* or co.
fix
Use yield* request(uri) inside a generator, or wrap with co.
ReferenceError: yield is not defined
Using yield outside of a generator function.
fix
Ensure the containing function is a generator (function*).
Upgrade
Version history
1.9latest on npm
Audit
Dependencies
corequiredRequired for generator-based async control flow; cogent itself returns a generator function.
Agent activity
22 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
cogent — npm install cogent · libregistry