我想从我的组件发出获取请求。我目前正在 componentWillMount 方法中制作它。所以这个组件是应用程序的第二页。第一个页面是登录页面。当我点击第一页上的登录按钮时,就会出现这个页面。发出 GET 请求时出现错误。这是我提出请求的方式
componentWillMount = ()=> {
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api/v1/workgroups/",
"method": "GET",
"headers": {
Authorization: "Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
},
success: function( data, textStatus, jQxhr ){
alert("success");
},
}
$.ajax(settings).done((response) => {
alert("yo");
console.log('check');
// this.context.router.push('/app')
});
}
这是网络和控制台选项卡的图像