1

when calling API in asyncData with static parameter meta working in both local and vercel server. but if parameter make dynamic live server meta not working

async asyncData(context) {
  let pageinfo = ''
 
  try {
    console.log(context.query.id)
    const url_key = 'cocomama-coconut-water-250ml'
    const custId = ''
    const guestId = ''
    const API_HEADER = Config.ADMIN_API_HEADER.headers
    API_HEADER.vendorUrlKey = 'centrealbazaarindialtdkaloor'

    pageinfo = await fetch(
      `${
        Config.BASE_URL
      }ProductDetails?urlKey=${url_key}&custId=${custId}&guestId=${guestId}`,
      {
        method: 'GET',
        headers: API_HEADER
      }
    ).then(res => res.json())

  
  } catch (error) {
    console.log(error)
  }

  pageinfo = pageinfo.Data.ProdDetails
  return { pageinfo }
}
kissu
  • 40,416
  • 14
  • 65
  • 133
  • Is `Config.BASE_URL` properly populated? Where is it buggy? Did you do see the value of `pageinfo` after the `fetch` and at the end to see what is wrong? – kissu Jul 29 '21 at 13:40
  • Also, I do recommend this one when you'll need to use env variables: https://stackoverflow.com/a/67705541/8816585 – kissu Jul 29 '21 at 14:52

0 Answers0