0
import React from 'react'

const RightBar = async () => {
  
  let data;
  

  try{
     const res = await fetch(`${process.env.NEXTAUTH_URL}/api/trendingtweets`);
     data = await res.json();
     
  } catch (error){
     
      return  error
    }
  

 
  return (
    <div className=' p-6 basis-1/4 sticky   h-[100vh] right-0 top-0'>
 
       {data?.tweetData?.map((ele)=>{
        return (
          <h1>
            {ele.tweet_id}
          </h1>
        )
       })}


      <div>
        <h2 className='my-2 ml-2 py-2 font-bold text-2xl'>Search</h2>
        <input type="text" placeholder='Search You Friend...' className='bg-slate-800  font-semibold py-2 pl-4 rounded-full' name="" id="" />
      </div>
       

        <div className='mt-6 mb-2 pt-6 pb-3 text-left'>
          <h2 className='text-2xl font-extrabold'>Whats happening!</h2>
        </div>


    </div>
  
  )
}

export default RightBar

How to use try catch in server component?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

0 Answers0