Created
June 23, 2021 07:14
-
-
Save Jerga99/bebb8bff8ea10ca9e18468056bf10377 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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