Is it OK if I use async in front of componentDidMount like this?
async componentDidMount() {
const key = '11a03b332b43ad4cde5';
try {
const response = await axios.get('https://api.unsplash.com/photos/?client_id=' + key);
this.setState({ imgs: response.data });
} catch (err) {
console.log('Error happened during fetching!', err);
}
}
It's working. But I wanted to ask to see if it is ok or is there any drawback to it.
Thanks