asxios--form data提交,setcookie
阿新 • • 發佈:2018-07-05
eee app lan sound ces sel pro baidu native
React native 項目,部分接口用form data 提交,以及在Android端,雖然設置了請求攜帶cookie,但每次請求攜帶的cookie跟初始化時都不一樣,目前做法是去到初始化中返回的userID保存下來,set到後面請求的cookie中,代碼如下:
axios.post(‘http://103.28.215.253:10528/knowledge/chat/process‘,"content="+a,{ 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項目目前踩坑階段,
asxios--form data提交,setcookie