Skip to content

Instantly share code, notes, and snippets.

@odirleiborgert
Created December 19, 2016 00:21
Show Gist options
  • Save odirleiborgert/c502905c676ff378b25c9af192943fec to your computer and use it in GitHub Desktop.
Save odirleiborgert/c502905c676ff378b25c9af192943fec to your computer and use it in GitHub Desktop.
import React from 'react';
import { Container, Divider, Card, Icon } from 'semantic-ui-react';
import axios from 'axios';
import SearchCar from './../services/SearchCar';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
title: 'List cars',
cars: []
}
}
render(){
var cars = [];
cars = SearchCar.getByTerm()
.then(function(response){
return response.data;
})
.catch(function(response){
console.log('erro');
});
const carList = cars.map(function(car){
return (
<div>
{car.id} - {car.model}
</div>
);
});
return (
<Container fluid>
<h1>olá React {this.state.title}</h1>
<Divider />
{carList}
</Container>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment