【发布时间】:2020-11-16 09:07:41
【问题描述】:
我是 React 和 AXIOS 的新手。我正在尝试将 API 调用中的数据(分配给用户的问题)呈现到我的页面上。在 (.then) 语句中运行函数是否有任何限制?
这是我的 AXIOS 请求
axios
.get(
"/api/v1/assigned-questions?userId=61d7d1be-4ada-4c1a-81c0-c6b82f45132e"
)
.then((res) => {
// handle success
const assignedQuestions = res.data[0];
// object with a collection of data
console.log(assignedQuestions);
this.setState({ currentUser: assignedQuestions });
})
.catch((error) => {
// handle error
console.log(error);
});
【问题讨论】:
标签: javascript mysql reactjs axios postman