<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NoorBhuiyan</title>
    <description>The latest articles on DEV Community by NoorBhuiyan (@noorbhuiyan).</description>
    <link>https://dev.to/noorbhuiyan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F895049%2F26803aa0-9b96-43a4-ad62-e58d470c3295.jpeg</url>
      <title>DEV Community: NoorBhuiyan</title>
      <link>https://dev.to/noorbhuiyan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/noorbhuiyan"/>
    <language>en</language>
    <item>
      <title>Next.js Dynamic Routes and getServersSideProps occur error while export</title>
      <dc:creator>NoorBhuiyan</dc:creator>
      <pubDate>Wed, 20 Jul 2022 11:45:19 +0000</pubDate>
      <link>https://dev.to/noorbhuiyan/nextjs-dynamic-routes-and-getserverssideprops-occur-error-while-export-1i4i</link>
      <guid>https://dev.to/noorbhuiyan/nextjs-dynamic-routes-and-getserverssideprops-occur-error-while-export-1i4i</guid>
      <description>&lt;p&gt;Actually I am new in Next.js and face such error that I never face before! I am doing my next project where I use getServerSideProps to fetch data. And it was a dynamic route ([id].js) The problem occur when I hit the build command to deploy the tiny project on my hosting.&lt;/p&gt;

&lt;p&gt;This is my next [id].js file –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import Related from './related';

export default function id(props) {
  return (
    &amp;lt;div&amp;gt;
    &amp;lt;div className="card"&amp;gt;
        &amp;lt;div className="card-title"&amp;gt;{props.data.title}&amp;lt;/div&amp;gt;
        &amp;lt;div className="card-body"&amp;gt;{props.data.body}&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;Related sendData={props.allData}/&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export const getServerSideProps =async (ctx)=&amp;gt;{
    const {params} = ctx;
    const res = await fetch(`https://jsonplaceholder.typicode.com/posts/${params.id}`)
    const data = await res.json()

    const allRes = await fetch('https://jsonplaceholder.typicode.com/posts/')
    const allData = await allRes.json();
    return{
        props:{
         data, allData
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is the error –&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Build error occurred Error: Export encountered errors on following
 paths: /blog/related at C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\export\index.js:395:19 at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Span.traceAsyncFn (C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\trace\trace.js:79:20) at async C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\build\index.js:1094:21 at async Span.traceAsyncFn (C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\trace\trace.js:79:20) at async C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\build\index.js:971:17 at async Span.traceAsyncFn (C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\trace\trace.js:79:20) at async Object.build [as default] (C:\Users\Hridoy\Desktop\demo blog\newapp\node_modules\next\dist\build\index.js:64:29)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to see the full code on github, this is here – &lt;a href="https://github.com/NoorBhuiyan/dynamic_route_error"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And Brother, can you help me by suggesting a better process for data fetching !&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
