I want to get an item from localstorage inside gatsby-node.js
I tried like this :
exports.onCreateNode = async function({ node, actions }) {
  const { createNode, createNodeField } = actions
  // here i used for localstorage item
  console.log(window.localStorage.getItem("token"))
  createNodeField({
    node,
    name: `happiness`,
    value: `is sweet graphql queries`,
  })
}
And got error like this :
"gatsby-node.js" threw an error while running the onCreateNode lifecycle:
localStorage is not defined
  19 | exports.onCreateNode = async function({ node, actions }) {
  20 |   const { createNode, createNodeField } = actions
> 21 |   console.log(localStorage.getItem("token"))
     |               ^
  22 |   createNodeField({
  23 |     node,
  24 |     name: `happiness`,
N.B. I have set data "token" in my localstorage
