title: Uncaught TypeError: Cannot read properties of null (reading 'content')
body: <p>I need your help to solve this error, it appeared out of nowhere, it was working normally, and now I don't know why I get this error with the X-CSRF-TOKEN.
  My head:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;es&quot;&gt;
  &lt;head&gt;
  &lt;meta charset=&quot;UTF-8&quot;&gt;
  &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;
  </code></pre>
  <p>My script:</p>
  <pre><code>&lt;script&gt;
  
    const csrfToken =  document.head.querySelector('meta[name=&quot;csrf-token&quot;]').content;                
    document.getElementById('_categoria').addEventListener('change',(e)=&gt;{
        fetch('subcategorias',{
            method : 'POST',
            body: JSON.stringify({texto : e.target.value}),
            headers:{
                'Content-Type': 'application/json',
                &quot;X-CSRF-Token&quot;: csrfToken
            }
        }).then(response =&gt;{
            return response.json()
        }).then( data =&gt;{
            var opciones =&quot;&lt;option value=''&gt;Elegir&lt;/option&gt;&quot;;
            for (let i in data.lista) {
               opciones+= '&lt;option value=&quot;'+data.lista[i].id+'&quot;&gt;'+data.lista[i].nombre+'&lt;/option&gt;';
            }
            document.getElementById(&quot;_subcategoria&quot;).innerHTML = opciones;
        }).catch(error =&gt;console.error(error));
    })
  
    document.getElementById('_subcategoria').addEventListener('change',(e)=&gt;{
        fetch('empresas',{
            method : 'POST',
            body: JSON.stringify({texto : e.target.value}),
            headers:{
                'Content-Type': 'application/json',
                &quot;X-CSRF-Token&quot;: csrfToken
            }
        }).then(response =&gt;{
            return response.json()
        }).then( data =&gt;{
            var opciones =&quot;&lt;option value=''&gt;Elegir&lt;/option&gt;&quot;;
            for (let i in data.lista) {
               opciones+= '&lt;option value=&quot;'+data.lista[i].id+'&quot;&gt;'+data.lista[i].nombre+'&lt;/option&gt;';
            }
            document.getElementById(&quot;_empresa&quot;).innerHTML = opciones;
        }).catch(error =&gt;console.error(error));
    })
  </code></pre>
     
  <p>I clarify that the script is for dynamic selects of 3 levels.</p>