
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
assert-ok-response
Advanced tools
A tiny helper to assert that response from fetch() is ok.
import { assertOkResponse } from 'assert-ok-response'
const response = await fetch('https://example.com/not-found')
await assertOkResponse(response)
//
// Throws:
//
// const err = new Error(`${errorMsg ?? `Cannot fetch ${res.url}`} (${res.status}): ${body}`)
// ^
//
// Error: Cannot fetch https://example.com/not-found (404): <!doctype html>
// [...]
// at assertOkResponse (file:///Users/bajtos/src/assert-ok-response/index.js:15:15)
// at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
// at async file:///Users/bajtos/src/assert-ok-response/x.js:4:1 {
// statusCode: 404,
// serverMessage: '<!doctype html>\n' +
// [...]
Error properties:
statusCode (number) - The HTTP status code of the response.serverMessage (string) - The response body returned by the server.npm test to run the tests.npm run lint:fix to fix linting issues.npx np to publish a new version.FAQs
A tiny helper to assert that response from `fetch()` is ok.
We found that assert-ok-response demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.