zoukankan      html  css  js  c++  java
  • axios post传参后台无法接收问题

    起因是在angular项目中使用axios发送post请求,向后台传参后台一直无法接收,网上查了有说是请求头设置不对,需要把Content-Type:application/x-www-form-urlencoded;charset=UTF-8

    改了之后发现还是不行,后来终于找到原因,axios请求中params和data,不一样,post需要把参数放在data中,get请求放在params中才行

    //POST请求
    sendIndentifyCodeServer(opt){ axios.post(`${environment.path}
    /IdentifyingCode/getVcode`,opt.data).then((response)=>{ if(opt.onSuccess){ opt.onSuccess(response); } }).catch(error=>{ if(opt.onFailed){ opt.onFailed(error); } }); }


    //GET请求
    sendIndentifyCodeServer(opt){ axios.get(`${environment.path}/IdentifyingCode/getVcode`,{params:opt.data}).then((response)=>{ if(opt.onSuccess){ opt.onSuccess(response); } }).catch(error=>{ if(opt.onFailed){ opt.onFailed(error); } }); }
  • 相关阅读:
    56. Merge Intervals
    Reorder List
    Merge Two Sorted Lists
    彻底删除kafka topic数据
    什么时候类加载
    checkpoint的作用
    case when
    SQL:将查询结果插入到另一个表的三种情况
    IFNULL函数
    kafka主要配置
  • 原文地址:https://www.cnblogs.com/leiting/p/8475552.html
Copyright © 2011-2022 走看看