React Call APIs
apiFunction = async() => {
try{
const response = await fetch(`http://url.com`);
const json = await response.json();
return json;
}
catch(err) {
throw err;
console.log(err);
}
}
async componentDidMount() {
try{
const response = await apiFunction();
console.log(response);
}
catch(err) {
console.log(err);
}
}
click for more React codes, read about react fetch