您的位置:首页 > Web前端

js fetch函数请求数据时带上cookie以解决请求数据时server端返回"请登录"的状态

2016-12-07 14:52 369 查看
fetch函数中带上 credentials: 'include'
getWatchHistory: function (version, spId, page, userId, callback, errorCallBack) {let url = URL + '/dev/user/watchHistory/list?version=' + version + '&spId=' + spId + '&page=' + page + '&userId=' + userId;fetch(url, {method: 'POST',credentials: "include"}).then((response)=>response.json()).then((responseJsonData)=> {callback && callback(responseJsonData);}).catch((error)=> {errorCallBack && errorCallBack(error);console.log("getWatchHistory error " + error);});},
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  fetch
相关文章推荐