I’ve been making a simple random movie generator app with react js and material ui but I’ve been having trouble with async functions. From what I understand, data isn’t grabbed from the API fast enough to provide it to the component I made. How do I correct this? Is there a way to make sure I grab the data before showing it? Also, how do I display an image link as an image on react? Any help would be great. Thanks!
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import { Grid } from '@material-ui/core';
import BTTF from "./BTTF.jpg";
import ratings from "./ratings.csv"
var movie;
var plot;
async function getData(){
const response = await fetch(ratings);
const movieData = await response.text();
const table = movieData.split('\n').slice(1);
const movieChoice = table[Math.floor(Math.random() * 171)];
const columns = movieChoice.split(',');
const id = columns[0];
const url = `http://www.omdbapi.com/?i=${id}&apikey=d3852437`;
const poster = `http://img.omdbapi.com/?i=${id}&apikey=d3852437`;
const responseAPI = await fetch(url);
const APIData = await responseAPI.json();
movie = APIData.Title;
plot = APIData.Plot;
console.log(APIData);
console.log(`URL: ${url} + ${poster}\n Movie: ${movie}\n Plot: ${plot}`);
}
getData();
const MovieCard = () =>{
const useStyles = makeStyles({
root: {
width: 300,
},
media: {
height: 435,
},
});
const classes = useStyles();
return <Grid container justify="center" alignItems="center" direction="column">
<Card className={classes.root}>
<CardActionArea>
<CardMedia
className={classes.media}
image={BTTF}
title={movie}
/>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
{getData.movie}
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
{plot}
</Typography>
</CardContent>
</CardActionArea>
<CardActions style={{justifyContent: 'center'}}>
<CardActions >
<Button variant="outlined" color="secondary">Generate</Button>
</CardActions>
</CardActions>
</Card>
</Grid>
}
export default MovieCard;
modafinil generic – gmrprovigi.com provigil a narcotic
price of accutane in india – accutane 5mg accutane prescription cost uk
generic vardenafil 20 mg – canadian generic vardenafil order vardenafil from canada
tadalafil daily use – buy cialis online paypal generic cialis online in uk
ivermectine – stromectol coupon ivermectin
generic lyrica medication – lyrica brand name canadian pharmacy oxycodone
sildenafil online prices – sildenafil San Jose order real viagra
covid and ivermectin – ivermectin 0.5 lotion india buy ivermectin canada
provigil dosage – modafinil generic provigil generic
buy generic azithromycin 100mg – buy azithromycin 250mg zithromax z pak 250 mg
lasix 10 mg – furosemide tablets 40mg lasix 100 mg tablet
generic clomid 50mg online – buy clomid 50mg generic for clomid
ventolin generic brand – ventolin cost albuterol inhaler
where to get cytotec – cytotec cost in india cytotec for sale usa
doxycycline medication pills – doxycycline 50 mg coupon buy doxycycline online usa
how to get neurontin – neurontin 2018 where to buy synthroid online without a prescription
cheap viagra 25mg – viagra over the counter uk viagra cheapest pharmacy
cialis 5mg for daily use – canadian pharmacy service viagra cialis levitra
vardenafil prices online – vardenafil free sample order levitra
buy prednisone with paypal canada – prednisone 2.5 mg rx prednisone 20 mg
accutane price in mexico – accutane 80 mg daily accutane 30mg
amoxil 500mg – amoxicillin price without insurance antibiotics without a doctor‘s prescription
methylprednisolone uk – lyrica 20 mg lyrica online prescription
pay for essay writing uk – essays custom write papers for me
buy viagra gel – Overnight canadian viagra sildenafil 100mg price uk
ivermectin cost in usa – cost of stromectol medicine ivermectin for humans walmart
buy prednisone online paypal – prednisone 5mg cost prednisone prices
ventolin price canada – ventolin price canada ventolin cost
best price for prescription doxycycline – doxycycline 3626 prednisolone 40 mg tablets
ivermectin gel – stromectol ivermectin 3 mg ivermectin without prescription
stromectol price us – stromectol tablets for humans for sale buy ivermectin cream
buy sildenafil online – best generic sildenafil sildenafil dosage
purchase tadalafil – buy tadalafil pills liquid tadalafil
buy 40mg accutane online – accutane pills isotretinoin 40mg
topical ivermectin cost – stromectol order ivermectin usa
25 mg viagra – Cialis prescription 5mg tadalafil price
amoxicillin tablets 250 mg
buy vardenafil – best ed pills new ed treatments
propecia-powered-by-phpbb
plaquenil adverse effects – 40 mg prednisone prednisone cost canada
prednisone 20 tablet
xenical 84 – orlistat levocarnitina xenical 120mg
otc cialis 2019
cialis without prescription
where to buy viagra online – viagra 100mg price buy viagra online australia
where to order cialis in canada – cialis price tadalafil best brand
can you buy prednisone over the counter uk – cost of prednisone best prednisone
zithromax medicine
ventolin cost without insurance
z pack duration
where can i buy cialis in canada – oralciapll cheap tadalafil 20 mg canada
cialis india order – US cialis cialis price in south africa
buy ivermectin 12mg online – stromectol rx stromectol tab
best college paper writing service – academic writing practice essay writing online
cialis online purchase
20 mg sildenafil cost – Pfizer viagra 50mg sildenafil 20 mg pills
ivermectin 12mg stromectol – ivermectin 12 mg over the counter ivermectin 12mg for humans
usa viagra over the counter
prednisone 20 mg – prednisone buy online deltasone 10 mg price
prednisone otc – prednixone tables for sale prednisone 20 mg tablet
diflucan one coupon
sildalis pill – buy glucophage 500mg online order generic metformin 1000mg
tab fluconazole 400
order ampicillin online cheap – cipro canada order hydroxychloroquine 400mg for sale
order plaquenil pills – hydroxychloroquine without prescription plaquenil without prescription
buy viagra 150mg generic – order viagra online cheap cialis online canada
generique viagra – viagra 25mg sans ordonnance en pharmacie cialis 10mg generique pas cher
amoxicillin price without insurance
ivermectin 0.5 lotion – cheap erectile dysfunction stromectol generic
albuterol sul hfa 90 mcg inh
buy pregabalin sale – buy cetirizine pills azithromycin pills
doxycycline 100mg tablet – buy gabapentin 800mg sale purchase levothyroxine generic
cenforce 100mg oral – cost cenforce brand acyclovir 400mg
atarax 25mg sale – buy rosuvastatin sale order rosuvastatin 20mg without prescription
buy chloroquine online cheap – viagra 150mg usa oral sildenafil
Simply wish to say your article is as amazing. The clarity
for your post is simply spectacular and that i can suppose you’re
a professional on this subject. Fine along with your permission let me to take hold of your feed to keep updated with coming near near post.
Thanks 1,000,000 and please keep up the rewarding work.
Ahaa, its fastidious dialogue regarding this article at
this place at this web site, I have read all that, so at this
time me also commenting at this place.
Wow! This blog looks exactly like my old one! It’s on a completely different subject but it has
pretty much the same page layout and design. Superb choice of colors!
Hi there all, here every person is sharing these know-how, thus
it’s good to read this webpage, and I used to pay a quick visit this website everyday.
Hello there! This blog post couldn’t be written any better!
Going through this post reminds me of my previous roommate!
He continually kept talking about this. I’ll send this post
to him. Pretty sure he will have a great read. Thanks for
sharing!