GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - CheckerNetwork/assert-ok-response: A tiny helper to assert that response from `fetch()` is ok

BranchesTags
Open more actions menu

Latest commit

 

History

120 Commits
120 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.gitignore
.gitignore
 
 
.prettierrc.yaml
.prettierrc.yaml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.js
eslint.config.js
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
test.js
test.js
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

assert-ok-response

A tiny helper to assert that response from fetch() is ok.

Usage

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.

Development

  • npm test to run the tests.
  • npm run lint:fix to fix linting issues.
  • npx np to publish a new version.

About

A tiny helper to assert that response from `fetch()` is ok

Resources

Readme
License
Activity
Custom properties

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.