-1
I’m making a website using React. When I run the GET method, I get the following result
On the front, the code is like this:
import React from 'react'
import axios from 'axios'
export default class ListaTarefas extends React.Component {
state = {
tarefas: []
}
componentDidMount() {
axios.get('http://localhost:3004/api/listaTarefas/')
.then(res => {
const tarefas = res.data
console.log(res.data)
this.setState({ tarefas })
})
}
render() {
return (
<ul>
{ this.state.tarefas.map(tarefa =>
<li key={tarefa._id}> {tarefa.nomeTarefa} </li>)}
</ul>
)
}
}
I can normally take the Filename, complete, etc, but I would like to know how to get the attribute Filename, which has other attributes.
did wrong on the line
const tarefas = res.data
actually isconst { tarefas } = res.data;
It already solves, it has the name right, but, I can’t remember now are so many names– novic
Dude, I tried that and no more results, started giving error in tasks.map also.
– rafacvs