1async function fetchFunction() {
2 try{
3 const response = await fetch(`http://url.com`);
4 const json = await response.json();
5 }
6 catch(err) {
7 throw err;
8 console.log(err);
9 }
10}
1 async componentDidMount() {
2 // when react first renders then it called componentDidMount()
3 const response = await fetch('https://jsonplaceholder.typicode.com/users');
4 const json = await response.json();
5 console.log(json);
6 }