title: SVELTE : Uncaught (in promise) TypeError: Cannot read property 'profile'
body: <p>I am using Svelte for one week and after authenticating on my app with cidaas-sdk, the profile data is not displayed after a few seconds. The page is stuck on &quot;... waiting&quot;, and this error in the console <code>Uncaught (in promise) TypeError: Cannot read property 'profile' of undefined at Array.create_if_block$1 at create_then_block$2</code></p>
  <p>The problem here is that I have to refresh the page to show the datas.</p>
  <p>My problem is i can't fetch <code>{userInfo.profile.given_name}</code> directly after log-in, so it's useless to reload the page to display the datas.
  But when the page is reloaded, everything is OK, no error messages in the console.</p>
  <pre><code>import cidaas from './helpers/cidaas';
  import Profile from './components/profile.svelte';
  import { onMount } from 'svelte';
  export let title;
  
  $ : isAuth = false;
  $ : isLoaded = false;
  
  let promiseHome = Promise.resolve([]);
  
  onMount(async () =&gt; {
      promiseHome = cidaas.getUserInfo();
          promiseHome.then(userInfo =&gt; {
          
      if(!userInfo) {
          // if you are logged
          if (window.location.href.includes(&quot;grant_type=login&quot;)) {
              cidaas.loginCallback();
              window.history.replaceState(&quot;&quot;, &quot;&quot;, &quot;/&quot;);
              isAuth = true;
              isLoaded = true;
              return;
          }
  
      }
    isAuth = !!userInfo;
    isLoaded = true;
    return;               
    })        
  });
  </code></pre>
  <p>HTML part :</p>
  <pre><code>{#await promiseHome}
      &lt;div class=&quot;mt-5&quot;&gt;...Waiting&lt;/div&gt;
  {:then userInfo} 
      {#if isAuth == true}
  
  
      &lt;div class=&quot;jumbotron col-md-8 mx-auto&quot;&gt;
          
      &lt;div class=&quot;hello mt-5 mb-3&quot;&gt;Hello {userInfo.profile.given_name}!&lt;/div&gt;
      &lt;p&gt;isAuth : {isAuth}&lt;/p&gt;
      &lt;p&gt;isLoaded : {isLoaded}&lt;/p&gt;
      &lt;/div&gt; 
      &lt;Profile/&gt;
  
      
          {:else}
          &lt;h1 class=&quot;mt-5&quot;&gt;Bienvenue sur {title}&lt;/h1&gt;
          &lt;p&gt;isAuth : {isAuth}&lt;/p&gt;
          &lt;p&gt;isLoaded : {isLoaded}&lt;/p&gt;
          &lt;button class=&quot;btn btn-primary btn-mdir&quot; on:click={loginTo}&gt;Se connecter&lt;/button&gt;
          &lt;button class=&quot;btn btn-primary btn-mdir&quot; on:click={register}&gt;S'inscrire&lt;/button&gt;
      
      {/if}
          {:catch error}
          &lt;p&gt;{error.message}&lt;/p&gt;
  {/await}
  </code></pre>