title: Variable used in localstorage is undefined
body: <p>I'm trying to save a token returned from the server into localStorage. But when I check in Chrome in the developer tools under "Application" for the stored item, it says   [object Object]. But when I console.log this variable, I get the full token which i'm trying to save.</p>
  
  <p>How can I save the token in my localstorage?</p>
  
  <p>Relevant Part:</p>
  
  <pre><code>GetToken(body){
      return new Promise((resolve,reject) =&gt; {
          body != null ? resolve(new Object(body)) : reject('Error');
      })
  }
  
  
  fetch(//-POST FUNCTION-//).then(response =&gt;{
          if (response.ok){
              this.GetToken(response).then(value =&gt; value.json())
                  .then( data =&gt; {
                      var servertoken = data; //token gets saved
                      localStorage.setItem('customtoken',servertoken); //variable is [object Object]
              })
          }
          else {
              console.log("wrong")
          }
      })
  </code></pre>