// var headers = new Headers(); // headers.append('Authorization', localStorage.getItem('token')); fetch('/distributor/sidebar',{ headers:{ 'Authorization':localStorage.getItem('token') } }).then(response => { return response.json(); // 先将结果转换为 JSON 对象 }) .then(data => { console.log(data); this.setState({ name:data.info.dealer_name, phone:data.info.username }); }).catch(function(error){ console.log(error); });