1
I need to list some records, but is returning me an error:
TypeError: clientes.map is not a function
import React, { Component } from 'react';
import api from '../src/services/api';
class App extends Component {
constructor(){
super();
this.state = {
clientes: [],
}
}
async componentDidMount() {
const response = await api.get('');
this.setState({clientes:response.data});
}
render() {
const { clientes } = this.state;
console.log(clientes)
return (
<div>
<h1>Listar os clientes</h1>
{clientes.map(cliente => (
<li key={cliente.show.id}>
<h2>
<strong>Título: </strong>
{cliente.recordsets.nrCadstro}
</h2>
</li>
))}
</div>
);
};
};
export default App;
here is my api
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:3333/clientes'
});
export default api;