I am trying to implement axios poling with React. I am expecting the get request to return a certain value but because it's async method I have to wait for it.
React method:
getInformationMessageOnSubmit = () => {
getInformationMessage().then(output =>
this.setState({message: output})
};
And I also have an axios request in a different file:
const getInfo = () => {
return axios.get('url')
.then(output => output)
.catch(error => console.log(error))
}
export const getInformationMessage = sealId => {
setInterval(() => getInfo(sealId), 1000);
};