I am working on a website dedicated to dynamic blogs and I need to pass parameters to an API URL in order to retrieve a specific blog. However, I must ensure that the approach I take does not hinder SEO by utilizing local storage, cookies, or any other client-side method. How can I effectively transmit data from one component to a server-side component?
import React from 'react'
import 'bootstrap/dist/css/bootstrap.min.css'
import "../../styles/style.css"
const fetchData = async () => {
try {
let slug = localStorage.getItem('auth')
let response = await fetch(`https://sankalpitsolutions.com/ecms/api/service_info.php?slug=${slug}`)
const backendHtmlString = await response.json()
return backendHtmlString
} catch (error) {
console.log(error)
}
}
async function displayPage(props) {
const serviceData = await fetchData()
return (
<>
<div dangerouslySetInnerHTML={{ __html: serviceData?.data?.description.replaceAll("&quot;", '"').replaceAll("&#39;", "'").replaceAll("amp;", "").replaceAll('<', '<').replaceAll('>', '>').replaceAll(""", '"').replaceAll('className', 'class').replaceAll('classname', 'class').replaceAll('&nbsp;', '') }}></div>
</>
)
}
export default displayPage