I created the following API object using python and im passing it to React using flask.
Im trying to plot all the results into a table like this:
| Date | Ps2 | ps2 emulator | ps2 games |
|---|---|---|---|
| 2020-01-26 | 64 | 61 | 52 |
| 2020-0202 | 70 | 45 | 71 |
For now Im trying to add into a table but Im only able to display the dates since its the only value I know. All the other ones vary depending on the user input. So ps5, ps2 emulator etc etc will change depending on user input.
My code is the following:
state = {
kws :[]
}
keyword = e => {
e.preventDefault();
axios.post("/trends",{search_keyword: document.getElementById("keywords").value})
.then((res) => {
const data = res.data
const keyword = []
for (var i in data)
{
keyword.push(data[i])}
console.log("this is variable keyword: " , keyword[1])
this.setState({kws: keyword[1]})
}
)}
ender() {
const {kws =[]} = this.state
return (
....
<Table hover>
<thead>
<tr>
<th>Keyword</th>
<th>Serarch Volume</th>
</tr>
</thead>
<tbody>
{kws.length ? kws.map(kws => (
<tr>
<td>{kws.date}</td>
<td>{kws.}</td>
<td>{kws.}</td>
<td>{kws.}</td>
</tr>
)):(
<h1> Loading </h1>)
}
</tbody>
</Table>
)
Also Is the way im formatting this json object correct? Or should I format it differently?
