Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[amis-editor] 表单 post 接口配置请求体 dataType 配置为 json 类型,未生效 #4754

Closed
rencoo opened this issue Jun 30, 2022 · 3 comments
Assignees

Comments

@rencoo
Copy link
Contributor

rencoo commented Jun 30, 2022

描述问题:

amis-editor 表单 post 接口配置请求体 dataType 配置为 json 类型,发送请求时,Content-Type 实际为 application/x-www-form-urlencoded

截图或视频:

截屏2022-06-30 22 46 14
截屏2022-06-30 22 46 54

如何复现(请务必完整填写下面内容):

  1. 使用官方编辑器项目,amis-editor-demo,版本为最新版本
    repository: https://github.com/aisuda/amis-editor-demo.git
    commitId: 1b5898b39764b74c5151b89a0755aaebfd42ba23

  2. 粘贴有问题的完整 amis schema 代码:

{
  "type": "form",
  "title": "表单",
  "body": [
    {
      "label": "文本框",
      "type": "input-text",
      "name": "text"
    }
  ],
  "api": {
    "method": "post",
    "url": "http://127.0.0.1:8082/api/create",
    "dataType": "json"
  },
  "id": "u:56ca5ce96d5f"
}
  1. 操作步骤
    使用最新版 amis-editor-demo,npm start 跑起项目后
    1)拖拽一个表单(具体schema配置就是上面👆🏻贴的 schema 代码)
    2)右侧操作面板,接口 > 高级配置,发送方式改为 POST,数据格式选择 JSON
    3)预览模式,发送请求,Content-Type 实际为 application/x-www-form-urlencoded
    4)退出编辑模式,发送请求,结果和预览模式一样
@rencoo
Copy link
Contributor Author

rencoo commented Jun 30, 2022

看起来是 amis-editor-demo 项目下 App.tsx 里,复写 fetcher 配置时出了bug
截屏2022-06-30 22 56 05
截屏2022-06-30 22 54 58

data 已经被序列化过了,然后三个判断条件都没走,config.headers里没有种上 application/json 的 Content-Type(config.headers['Content-Type'] = 'application/json'; 这句没被执行导致的)

@wibetter
Copy link
Collaborator

已经修复,
image

@rencoo
Copy link
Contributor Author

rencoo commented Jul 18, 2022

已经修复, image

有提交记录吗,麻烦贴一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants