@@ -15,51 +15,40 @@ const EntityType = {
1515} ; 
1616
1717function  FetchUrlIntoSession ( url ,  updateCurrentToken )  { 
18-     return  fetch ( url ) . then ( function  ( response )  { 
19-         if  ( response . ok )  { 
20-             return  response . json ( ) 
21-             . then ( function  ( embedConfig )  { 
22-                 setSession ( embedConfig . embedToken . token ,  embedConfig . embedUrl ,  embedConfig . id ,  embedConfig . dashboardId ) ; 
23-                 SetSession ( SessionKeys . SampleId ,  embedConfig . id ) ; 
24- 
25-                 if  ( updateCurrentToken ) 
26-                 { 
27-                     var  embedContainerId ; 
28-                     if  ( embedConfig . type  ===  "dashboard" )  { 
29-                         embedContainerId  =  "dashboardContainer" ; 
30-                     }  else  if  ( embedConfig . type  ===  "report" )  { 
31-                         embedContainerId  =  "embedContainer" ; 
32-                     }  else  { 
33-                         embedContainerId  =  "tileContainer" 
34-                     } 
35- 
36-                     var  embedContainer  =  powerbi . embeds . find ( function ( embedElement )  { return  ( embedElement . element . id  ==  embedContainerId ) } ) ; 
37-                     if  ( embedContainer ) 
38-                     { 
39-                         embedContainer . setAccessToken ( embedConfig . embedToken . token ) ; 
40-                     } 
41-                 } 
42- 
43-                 if  ( embedConfig . type  ===  "report" ) 
44-                 { 
45-                     LastReportSampleUrl  =  url ; 
46-                     TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Report ) ; 
47-                 } 
48-                 else  if  ( embedConfig . type  ===  "dashboard" ) 
49-                 { 
50-                     TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Dashboard ) ; 
51-                 } 
52-                 else  
53-                 { 
54-                     TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Tile ) ; 
55-                 } 
56-             } ) ; 
18+     return  $ . getJSON ( url ,  function  ( embedConfig )  { 
19+         setSession ( embedConfig . embedToken . token ,  embedConfig . embedUrl ,  embedConfig . id ,  embedConfig . dashboardId ) ; 
20+         SetSession ( SessionKeys . SampleId ,  embedConfig . id ) ; 
21+ 
22+         if  ( updateCurrentToken ) 
23+         { 
24+             var  embedContainerId ; 
25+             if  ( embedConfig . type  ===  "dashboard" )  { 
26+                 embedContainerId  =  "dashboardContainer" ; 
27+             }  else  if  ( embedConfig . type  ===  "report" )  { 
28+                 embedContainerId  =  "embedContainer" ; 
29+             }  else  { 
30+                 embedContainerId  =  "tileContainer" 
31+             } 
32+ 
33+             var  embedContainer  =  powerbi . embeds . find ( function ( embedElement )  { return  ( embedElement . element . id  ==  embedContainerId ) } ) ; 
34+             if  ( embedContainer ) 
35+             { 
36+                 embedContainer . setAccessToken ( embedConfig . embedToken . token ) ; 
37+             } 
5738        } 
58-         else  { 
59-             return  response . json ( ) 
60-             . then ( function  ( error )  { 
61-                 throw  new  Error ( error ) ; 
62-             } ) ; 
39+ 
40+         if  ( embedConfig . type  ===  "report" ) 
41+         { 
42+             LastReportSampleUrl  =  url ; 
43+             TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Report ) ; 
44+         } 
45+         else  if  ( embedConfig . type  ===  "dashboard" ) 
46+         { 
47+             TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Dashboard ) ; 
48+         } 
49+         else  
50+         { 
51+             TokenExpirationRefreshListener ( embedConfig . minutesToExpiration ,  EntityType . Tile ) ; 
6352        } 
6453    } ) ; 
6554} 
0 commit comments