Registry /
http-networking / cerebral-http-bugfix-1210
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HttpProvider
✓ import HttpProvider from '@cerebral/http'
✗ const HttpProvider = require('@cerebral/http')
Default export; CJS require may work but is not recommended.
httpGet, httpPost, httpPut, httpDelete, httpPatch
✓ import { httpGet } from '@cerebral/http/operators'
✗ import { httpGet } from '@cerebral/http'
Operator factories are in '@cerebral/http/operators', not the main module.
HttpProviderError
✓ import { HttpProviderError } from '@cerebral/http'
✗ import HttpProviderError from '@cerebral/http'
Named export, not default.
Shows setup of HttpProvider with baseUrl, a signal that does a GET request, and updates state.
import { Controller, Module } from 'cerebral';
import HttpProvider from '@cerebral/http';
const http = HttpProvider({
baseUrl: 'https://api.example.com',
headers: { 'Content-Type': 'application/json' },
withCredentials: false,
});
const app = Module({
providers: { http },
state: { items: [] },
signals: {
fetchItems: [
function getItems({ http, state }) {
return http.get('/items')
.then(response => ({ result: response.result }));
},
({ state, props }) => { state.set('items', props.result); },
],
},
});
const controller = Controller(app);
// Use with UI framework (React etc.)
Errors
Common errors & fixes
Cannot find module '@cerebral/http/operators'
The package does not ship operators in the main entry; some bundlers may resolve incorrectly.
fixEnsure your bundler supports package.json exports or import directly from '@cerebral/http' (main module) and use actions instead.
TypeError: http.get is not a function
HttpProvider not added to controller's providers array.
fixAdd `providers: { http: HttpProvider({...}) }` in your Module definition. Uncaught (in promise) HttpProviderError: Failed to fetch
CORS issue or network error; request failed.
fixCheck CORS headers on server, enable withCredentials if needed, or verify URL.
Audit
Dependencies
cerebralrequiredPeer dependency; requires cerebral ^4.0.1 (not compatible with cerebral v5/v6)