fix(h5): unify the default content-type #7796
Merged
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.
这个 PR 做了什么? (简要描述所做更改)
将

Taro.request
中content-type
的默认值设置为application/json
,使其和官方文档中的描述一致,方便开发者使用。这个 issue 最初报在 #1280, 现在可以使用 https://github.com/yuezk/taro_bug/tree/master/h5_request__contentType 复现
翻了一下代码的历史记录,发现 #1280 被 103f730 这个 commit 修复,但随后又被 revert 了。看了一下修复的方法,发现原来的方案中添加默认的
content-type
的位置不对,这会导致给所有的没有设置content-type
的请求设置一个application/json
的content-type
,进而会使一些请求出问题。比较的合适的时机应该当传入的
data
是 object,并且没有指定content-type
的时候,给content-type
一个默认值application/json
。这个 PR 是什么类型? (至少选择一个)
这个 PR 满足以下需求:
这个 PR 涉及以下平台:
其它需要 Reviewer 或社区知晓的内容: