-2
Why the table only appears data if you set the position of the element in the array?
import React from 'react'
import Head from 'next/head'
import { Table } from 'reactstrap'
import axios from 'axios'
import Menu from '../components/Menu'
import 'bootstrap/dist/css/bootstrap.min.css'
const AreaTematica = (data) => (
<div>
<Head>
<title>Áreas Temáticas</title>
<meta name='robots' content='index, follow' />
<meta name='description' content='Módulo de Áreas Temáticas' />
</Head>
<Menu />
<Table striped>
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
</tr>
</thead>
<tbody>
<tr>
<td>{data.response.areatematica.docs[0]._id}</td>
<td>{data.response.areatematica.docs[0].nome}</td>
</tr>
</tbody>
</Table>
</div>
)
AreaTematica.getInitialProps = async () => {
const response = await axios.get('http://localhost:8080/areastematicas')
return { response: response.data }
}
export default AreaTematica
I was wondering what you want to do. The answer you get from Axios is an array, and you want each item of the array to be a row in the table?
– Júlio Moura
that’s right. each item in a row.
– Fabio Moura