Skip to content
Discussion options

You must be logged in to vote

We'll soon have updated examples (literally resolving some internal comments on my updated document)

In this case, you can refactor.

import { cookies } from "next/headers";

async function CookieSection() {
  const cookieStore = await cookies();
  const deviceUniqueId = cookieStore?.get("uniqueId")?.value
  
  const data = await fetchWithUniqueId(deviceUniqueId ?? 'no-unique-id-found');
  
  return <>SomeJSX</>
}

export default function Page() {
   return <Suspense fallback={<p>Some meaningful UI</p>}><CookieSection /></Suspense>
}

And then do:

async function fetchWithUniqueDeviceId(deviceId: string) {
  'use cache'
  const response = await fetch(url, {
      headers: {
        'x-trace-id'

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@abhishekmardiya
Comment options

@icyJoseph
Comment options

@abhishekmardiya
Comment options

@icyJoseph
Comment options

@abhishekmardiya
Comment options

Answer selected by abhishekmardiya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants