Post.getInitialProps = async ({query, req}) => {
//console.log(query);
if(!req){
return ({post: null})
}
const postApi = await fetch(`https://jsonplaceholder.typicode.com/posts/${query.id}`);
const post = await postApi.json();
//Получаем id пользователя
const userId = post.userId;
const userApi = await fetch(`https://jsonplaceholder.typicode.com/users/${userId}`);
const user = await userApi.json();
return ({post: post, name: user.username});
}