-2
import React, { Component, Fragment } from 'react';
import $ from 'jquery';
export class ListaFilmes extends Component{
constructor() {
super();
this.state = {
filmes: [],
}
}
componentDidMount() {
$.ajax({
url: "http://localhost:3000/filmes?page=1",
type: 'GET',
dataType: 'json',
contentType: 'application/json',
success: function (resposta) {
this.setState({filmes: resposta});
console.log(resposta);
}.bind(this),
error: function (data) {
console.log(data)
}
});
}
render(){
return(
<div>
{this.state.filmes.map((item) =>
<li key={item.results}>{item.results}</li>
)}
</div>
)
}
}
Nunhuma of these solves your problem? It seems that this is a common error in React
– Costamilam