Version 1.2.0
Full Changelog: v1.1.3...v1.2.0
✨ New Feature: Skip Status Check Option
Added a new skipStatusCheck option to IFetchOptions that allows you to bypass HTTP status validation and handle responses with custom status codes.
Use Case: This is useful when working with APIs that use non-standard status codes or when you need to handle the response yourself regardless of the HTTP status.
Example:
await fetchEventData('/api/sse', {
skipStatusCheck: true,
onOpen: (res) => {
// This will be called even if status is not 2xx
console.log('Response status:', res.status);
if (res.status === 299) {
// Handle custom status code
}
},
onMessage: (event) => {
console.log(event.data);
}
})Key Features:
- ✅ Backward compatible (default:
false) - ✅ Allows custom status code handling
- ✅ Maintains existing error handling behavior when disabled
- ✅ Fully tested with comprehensive test coverage
📝 Changes
Features
- Add
skipStatusCheck?: booleanoption toIFetchOptionsinterface - Implement conditional status check logic in
fetchEventData - Add comprehensive test suite for the new option
Documentation
- Update README with usage examples and API documentation
- Add detailed explanation of the new option's behavior
Tests
- Add 4 new test cases covering:
- Default behavior (status check enabled)
- Error handling with default behavior
- Custom status code handling with
skipStatusCheck: true - Non-2xx status code processing
🔧 Technical Details
Implementation: When skipStatusCheck is set to true, the onOpen callback is invoked immediately after receiving the response, bypassing the checkOk() validation. This allows users to inspect and handle the response object directly, regardless of the HTTP status code.
Breaking Changes: None. This is a fully backward-compatible addition.
📦 Installation
npm install fetch-sse@1.2.0Full Changelog: cc731e5...v1.2.0