Skip to content

Add FormData type for data in fetchSyncPost #10715

Closed
@frostime

Description

@frostime
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

fetchSyncPost 在实现中,对于一切 data 参数不加区分地设定为 json 类型,但是后端 API 中,有些请求(如 upload, putFile 等)的body的类型是 HTMLForm。所以在使用这个 API 发这些请求的时候会出现错误。

见:

if (data instanceof FormData) {

和:

if (data) {

Expected result

请修复 fetchSyncPost 的实现,让其对不同类型更加鲁棒。

Screenshot or screen recording presentation

No response

Version environment

- Version: 3.0.4
- Operating System: win10
- Browser (if used): No

Log file

More information

No response

Activity

changed the title [-]Bug | 插件 API `fetchSyncPost` 的 `data` 参数不能只是 json[/-] [+]Bug | 插件 API `fetchSyncPost` 的 `data` 参数类型问题[/+] on Mar 24, 2024
self-assigned this
on Mar 24, 2024
added this to the 3.0.5 milestone on Mar 24, 2024
added a commit that references this issue on Mar 24, 2024
changed the title [-]Bug | 插件 API `fetchSyncPost` 的 `data` 参数类型问题[/-] [+]Add `FormData` type for `data` in `fetchSyncPost` [/+] on Mar 24, 2024
changed the title [-]Add `FormData` type for `data` in `fetchSyncPost` [/-] [+]Add `FormData` type for `data` in `fetchSyncPost` [/+] on Mar 25, 2024
changed the title [-]Add `FormData` type for `data` in `fetchSyncPost` [/-] [+]Add `FormData` type for `data` in `fetchSyncPost`[/+] on Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Vanessa219@frostime

      Issue actions

        Add `FormData` type for `data` in `fetchSyncPost` · Issue #10715 · siyuan-note/siyuan