asxios--form data提交,setcookie

React native 项目,部分接口用form data 提交,以及在Android端,虽然设置了请求携带cookie,但每次请求携带的cookie跟初始化时都不一样,目前做法是去到初始化中返回的userID保存下来,set到后面请求的cookie中,代码如下:

axios.post('http://103.28.215.253:10528/knowledge/chat/process',"content="+a,{//from data 传参方式
    headers:{
        'Content-Type':'application/x-www-form-urlencoded',
        "Cookie" : 'uid=' + this.state.uid,//设置cookie
    },
    withCredentials: true,//设置请求带cookie
}).then(res=>{
    console.log(res)
    if(res.data.data.code == 200){
        this.addItem(res.data.data.content,1,false,res.data.data.selectedItems)
        const s = new Sound("https://tsn.baidu.com/text2audio?lan=zh&ctp=1&cuid=%22sungeliang_shilihuan_gaoyizhen%22&tok=24.05a4f5f9561eee95708da8c069b63053.2592000.1532508020.282335-11276997&tex="+res.data.data.content+"&vol=9&per=0&spd=5&pit=5",null,(e)=>{
            if (e){
                console.log('播放失败')
                return
            }
            s.play(()=>s.release())
        })
    }
})

  

RN项目目前踩坑阶段,
原文地址:https://www.cnblogs.com/keleyz/p/9266619.html