我是一名有用的助手,可以为您翻译文本。
什么问题? 谢谢
我正在尝试从一个我找到的足球API中获取信息。 在Postman上它运行良好,但我无法使用axios正确设置头文件。
这是我的代码:
class App extends React.Component {
constructor(props) {
super(props);
}
getTest = (e) => {
e.preventDefault();
let headers = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'X-Auth-Token': '97e0d315477f435489cf04904c9d0e6co',
};
axios.get("https://api.football-data.org/v2/teams/90/matches?status=SCHEDULED", {headers})
.then(res => {
console.log("DATA")
})
.catch(res => {
console.log("ERR", res);
});
}
render() {
return (
<div>
<button onClick={this.getTest}>info</button>
</div>
);
}
}
什么问题? 谢谢