小鼎
小鼎
  • 发布:2018-10-18 12:01
  • 更新:2021-09-01 17:28
  • 阅读:10986

uni.request提交数据,后台获取不到

分类:uni-app

uni.request提交的json数据,后台无法获取,用postmain工具可以获取到

2018-10-18 12:01 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

检查下请求头里面的 Content-type 是否一致,并且符合后端的约定。

  • 小鼎 (作者)

    谢谢,已经解决了 Content-type换成application/x-www-form-urlencoded就可以了

    2018-10-18 15:44

y***@163.com

y***@163.com

同样遇到此问题, 啊求解决方案

quanpeifeng

quanpeifeng - 开发

你好 !你这个问题 解决了吗?

h***@163.com

h***@163.com - Hickup

刚刚测试玩的时候,正好也遇到了这个问题,像上面说的,把请求头里面的Content-type改正确就对了
uni.request({
url:"http://localhost/login",
header:{
'Content-type':'application/x-www-form-urlencoded'
},
method:"POST",
data:{
username:"cun",
password:"123"
},

                success:function(res){  
                    console.log(res.data);  
                    var jwtToken=res.data.jwtToken;  
                    var msg=res.data.msg;  
                    var stauts=res.data.status;  

                }  
            })
  • 4***@qq.com

    改成这个type就和get方式没区别了啊 中文参数不会乱码?

    2019-06-26 11:13

jtshushu

jtshushu - 擅长:PHP-Thinkphp Python MUI UniApp Vuejs Bootstrap Jq Logo设计 广告设计 网页设计 有项目上需要联系我微信号:jtshushu66

测试很久总是 解决了 最后是编码吗


header : {  
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'  
}
  • 8***@qq.com

    post如果data是json一般要这样写header 'content-type': 'application/x-www-form-urlencoded'

    2020-06-30 09:13

k***@163.com

k***@163.com

请问解决了嘛?我能获取到参数,但是3个参数里面只能获取到一个,后面两个没有值,但是我console都能打印出来值

1***@qq.com

1***@qq.com

还有一种可能是强制了https访问,现实却是用http访问的

该问题目前已经被锁定, 无法添加新回复