Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Data displayed on server side but is partially undefined at client side

I am trying to fetch data from airtable base and displaying it on client side, the table contains following columns:-

Id, name, formatted_address, cross_street, voting and imageURL.

I am able to display id name image and voting on the client side but formatted_address and cross_street is undefined on the client side but the data is displayed on the server side in Next.js app.

const CoffeeStore = (initialProps) => {
  const router = useRouter();

  const id = router.query.id;

  const [coffeeStore, setCoffeeStore] = useState(initialProps.coffeeStore);

  const {
    state: { coffeeStores },
  } = useContext(StoreContext);

  useEffect(() => {
    if (isEmpty(initialProps.coffeeStore)) {
      if (coffeeStores.length > 0) {
        const coffeeStoreFromContext = coffeeStores.find((coffeeStore) => {
          return coffeeStore.fsq_id.toString() === id; //dynamic id
        });

        if (coffeeStoreFromContext) {
          setCoffeeStore(coffeeStoreFromContext);
        }
      }
    }
  }, [id, initialProps.coffeeStore]);

  const { data, error } = useSWR(`/api/getStoreById?id=${id}`, fetcher);

  useEffect(() => {
    if (data && data.length > 0) {
      console.log("SWR DATA>>>>", data[0]);
      setCoffeeStore(data[0]);
      setVotingCount(data[0].voting);
    }
  }, [data]);

  const {
    name,
    imageURL,
    location: { formatted_address } = "NA",
    location: { cross_street } = "NA",
  } = coffeeStore;

  console.log("COffee STore>>>", coffeeStore);

formatted_address and cross_street is undefined on client side but is displayed on server side.

  console.log(
    id,
    name,
    formatted_address,
    cross_street,
    imageURL
  );
};

export default CoffeeStore;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!