I have my user id stored in local storage and I want to access it in the getStaticProps
to fetch the subscribers of current user but I am getting Local storage is not defined
error.
Any solutions please?
Here is my code:
export async function getStaticProps() {
const userData = {
id: localStorage.getItem("user_id"),
};
const subscribersAPi = await fetch(
`url for server`
);
const result = await subscribersAPi.json();
return {
props: { data: result },
};
}