Skip to content

Instantly share code, notes, and snippets.

@Jerga99
Created June 23, 2021 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jerga99/bebb8bff8ea10ca9e18468056bf10377 to your computer and use it in GitHub Desktop.
Save Jerga99/bebb8bff8ea10ca9e18468056bf10377 to your computer and use it in GitHub Desktop.
import { Container, Jumbotron } from "reactstrap";
import axios from "axios";
function CarPage({car: { name, model, description, pdate, sdate,pprice, sprice, profit }}){
return(
<>
<Container>
<Jumbotron>
<h1 className="display-4">{ name }</h1>
<h2 className="display-4">{ model }</h2>
<p className="lead">{ description }</p>
<hr className="my-4" />
<h3>{ pdate }</h3>
<h3>{ sdate }</h3>
<h3>{ pprice }</h3>
<h3>{ sprice }</h3>
<h3>{ profit }</h3>
</Jumbotron>
</Container>
</>
)
}
export async function getServerSideProps({ params: { id } }) {
const url = `http://localhost:3000/api/cars`;
const response = await axios.get(`${url}/${id}`);
return { props: {
car: response.data
}
};
}
export default CarPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment