我正在尝试使用React实现axios极化。我期望get请求返回某个值,但是因为它是异步方法,所以我必须等待它。
反应方法:
getInformationMessageOnSubmit = () => {
getInformationMessage().then(output =>
this.setState({message: output})
};
我在另一个文件中也有一个axios请求:
const getInfo = () => {
return axios.get('url')
.then(output => output)
.catch(error => console.log(error))
}
export const getInformationMessage = sealId => {
setInterval(() => getInfo(sealId), 1000);
};