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); } }); }
  • 相关阅读:
    汇编笔记
    C++知识点复习
    flask 初步
    flask and postgre on heroku
    google zxing二维码库 初始
    flasklogin解读
    flasksqlalchemy 关系(一对多)
    flask的信号
    flask 范例学习
    github 操作纪录
  • 原文地址:https://www.cnblogs.com/leiting/p/8475552.html
Copyright © 2011-2022 走看看