title: Using localstorage in google amp
body: <p>I have been trying to store some data on localStorage after response of a <a href="https://amp.dev/documentation/components/amp-form/" rel="nofollow noreferrer">amp-form</a> using custom script (amp-script) in  form's <a href="https://amp.dev/documentation/components/amp-form/#events" rel="nofollow noreferrer">submit-success</a> in an amp page.</p>
  <p>According to <a href="https://github.com/ampproject/worker-dom/blob/master/web_compat_table.md" rel="nofollow noreferrer">API compatibility table</a> by <a href="https://amp.dev" rel="nofollow noreferrer">amp.dev</a>, Window.localStorage is allowed.</p>
  <p>But I'm getting <code>Type must be specified</code> error in console by using amp-script</p>
  <p><a href="https://i.stack.imgur.com/jAcwn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jAcwn.png" alt="type must be specified console error screenshot" /></a></p>
  <br />
  <h3>Code</h3>
  <pre><code>&lt;form
      method=&quot;post&quot;
      target=&quot;_top&quot;
      className=&quot;body&quot;
      action-xhr={`//localhost:4000/check-user`}
      custom-validation-reporting=&quot;show-all-on-submit&quot; &gt;
  
      ----------------------
      ----- form inputs ----
      ----------------------
  
      &lt;div className=&quot;success_message&quot; submit-success=&quot;true&quot;&gt;
          &lt;amp-script width=&quot;200&quot; height=&quot;50&quot; script=&quot;store_data&quot;&gt;&lt;/amp-script&gt;
      
          &lt;script id=&quot;store_data&quot; type=&quot;text/plain&quot; target=&quot;amp-script&quot;&gt;
              Window.localstorage.setItem(&quot;__t&quot;, randomGUID(19)); // randomGUID returns a random alphanumeric string of specified length
          &lt;/script&gt;
      &lt;/div&gt;
  
  &lt;/form&gt;
  </code></pre>
  <p>Any help will be appreciated
  Thanks</p>