I'm using next.js and call my API calls in getInitialProps() and map them to props and its just fine. but when I get my page without JavaScript (like with chrome view-source:localhost) it's not rendering correctly.
this is my getInitialProps():
static async getInitialProps(props) {
const res = await REQUEST_getCar();
return {
//this is for https://github.com/isaachinman/next-i18next
namespacesRequired: ['common'],
...res
};
}
and this is my first
render() {
const { t, start, end, search_id } = this.props;
const { error } = this.state;
const { media_set, year, mileage_range, owner, body_style, color, color_code, cancellation_policy, transmission_type, location, facility_set, description, capacity, car } = this.props;
return (
<div>
<p>{description}</p>
<p>{capacity}</p>
</div>
);
but all I get inside my body tag is:
<body>
<div id="page"><div id="__next"></div></div>
<script src="/_next/static/development/dll/dll_08aba1a94b9aff9fbcb5.js"></script>
<script>
__NEXT_DATA__ = {
props: {
initialI18nStore: {},
initialLanguage: null,
i18nServerInstance: null,
pageProps: {
namespacesRequired: ['common'],
rentalCarID: '31',
start: '1398/03/12',
end: '1398/03/16',
search_id: '0d79a3db-8b0b-4a23-a10f-685fffdcdbcb',
year: { fa: '۲۰۱۹ - ۱۳۹۸', en: '2019 - 1398' },
mileage_range: {
end: 100000,
start: 50000,
id: 2,
priority: 1
},
avg_price_per_day: 250000,
body_style: { fa: 'سواری', en: 'Passenger Car' },
color: { fa: 'قرمز', en: 'Red' },
color_code: '#FF0000',
cancellation_policy: null,
description: 'some test description',
capacity: 5,
car: {
id: 705,
capacity: 5
},
facility_set: [{ id: 24, name: 'Audio Input' }],
loaded: true,
media_set: [
'/media/17/i/20190507/1557234331_15e443c2e330.jpg',
'/media/17/i/20190507/1557234331_658460b2eb99.jpg'
]
}
},
page: '/car',
query: {
id: '31',
start: '1398/03/12',
end: '1398/03/16',
search_id: '0d79a3db-8b0b-4a23-a10f-685fffdcdbcb'
},
buildId: 'development'
};
__NEXT_LOADED_PAGES__ = [];
__NEXT_REGISTER_PAGE = function(r, f) {
__NEXT_LOADED_PAGES__.push([r, f]);
};
</script>
<script async="" id="__NEXT_PAGE__/car" src="/_next/static/development/pages/car.js"></script>
<script async="" id="__NEXT_PAGE__/_app" src="/_next/static/development/pages/_app.js"></script>
<script async="" id="__NEXT_PAGE__/_error" src="/_next/static/development/pages/_error.js">
</script>
<script src="/_next/static/runtime/webpack.js" async=""></script>
<script src="/_next/static/runtime/main.js" async=""></script>
</body>
why is that and how I can debug next.js to find out why the render method is not working? could it be because of my dependencies?