fix: Ensure checkOk is called after fetch response #6#7
Open
clddup wants to merge 1 commit intoyokingma:mainfrom
Open
fix: Ensure checkOk is called after fetch response #6#7clddup wants to merge 1 commit intoyokingma:mainfrom
clddup wants to merge 1 commit intoyokingma:mainfrom
Conversation
Owner
|
Hi @clddup, 感谢你的 PR!我理解你想要在自定义状态码场景下让 不过,直接改变调用顺序会是一个 breaking change,因为这会改变 API 的默认行为 —— 即使响应状态码是错误的(如 4xx、5xx), 更好的方案我已经在 main 分支实现了一个更好的解决方案:添加了一个 ✅ 向后兼容 - 默认行为不变,不会破坏现有代码 使用方式await fetchEventData('/api/sse', {
skipStatusCheck: true, // 跳过状态检查
onOpen: (res) => {
// 即使状态码不是 2xx 也会被调用
console.log('Response status:', res.status);
if (res.status === 299) {
// 处理自定义状态码
}
},
onMessage: (event) => {
console.log(event.data);
}
})相关提交
你可以直接使用最新版本的 如果有任何问题或建议,欢迎继续讨论! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title:
Description: (optional)
Motivation: (optional)
Related Issues: (optional)