axios 使用post 发送表单数据 后台收到了请求,但是没有内容?

查看:643
本文介绍了axios 使用post 发送表单数据 后台收到了请求,但是没有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

代码是这样的

          this.$http({
            method: 'post',
            url: 'http://192.168.1.108:3000/login',
            data: {
              username: '11111',
              password: '11111'
            },
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
          })
          .then(function (response) {
            console.log(response);
            if(response.body != null & response.body.length > 0){
              this.$store.commit('isLogin',response.body[0]);
              this.loginForm.userName=''
              this.loginForm.pwd= ''
              this.$router.push({ path: '/login' })
              this.dialogVisible = false;
            }else{
              alert('请输入正确的用户名和密码!!!');
              this.loginForm.userName=''
              this.loginForm.pwd= ''
            }

后台收到了我的请求,但是好像是说里面没有数据(data里的username和password没发过去)
我收到的responsed是这样的

解决方案

发送过去的数据格式不对吧,如果对的话,那后端必然会接收到的

这篇关于axios 使用post 发送表单数据 后台收到了请求,但是没有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆