File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
apps/playground/src/pages/apis/txbuilder/governance
packages/mesh-common/src/utils Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function Left() {
3434
3535 let codeAnchor = `` ;
3636 codeAnchor += `async function getMeshJsonHash(url: string) {\n` ;
37- codeAnchor += ` var drepAnchor = getFile(url);\n` ;
37+ codeAnchor += ` var drepAnchor = await getFile(url);\n` ;
3838 codeAnchor += ` const anchorObj = JSON.parse(drepAnchor);\n` ;
3939 codeAnchor += ` return hashDrepAnchor(anchorObj);\n` ;
4040 codeAnchor += `}\n` ;
@@ -129,7 +129,7 @@ function Right() {
129129 const [ anchorUrl , setAnchorUrl ] = useState < string > ( "" ) ;
130130
131131 async function getMeshJsonHash ( url : string ) {
132- var drepAnchor = getFile ( url ) ;
132+ var drepAnchor = await getFile ( url ) ;
133133 const anchorObj = JSON . parse ( drepAnchor ) ;
134134 const anchorHash = hashDrepAnchor ( anchorObj ) ;
135135 return anchorHash ;
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ function Right() {
6565 const [ anchorUrl , setAnchorUrl ] = useState < string > ( "" ) ;
6666
6767 async function getMeshJsonHash ( url : string ) {
68- var drepAnchor = getFile ( url ) ;
68+ var drepAnchor = await getFile ( url ) ;
6969 const anchorObj = JSON . parse ( drepAnchor ) ;
7070 const anchorHash = hashDrepAnchor ( anchorObj ) ;
7171 return anchorHash ;
Original file line number Diff line number Diff line change 1- export function getFile ( url : string ) {
2- var Httpreq = new XMLHttpRequest ( ) ;
3- Httpreq . open ( "GET" , url , false ) ;
4- Httpreq . send ( null ) ;
5- return Httpreq . responseText ;
1+ export async function getFile ( url : string ) {
2+ if ( typeof XMLHttpRequest !== "undefined" ) {
3+ var Httpreq = new XMLHttpRequest ( ) ;
4+ Httpreq . open ( "GET" , url , false ) ;
5+ Httpreq . send ( null ) ;
6+ return Httpreq . responseText ;
7+ } else {
8+ const res = await fetch ( url ) ;
9+ return res . text ( ) ;
10+ }
611}
You can’t perform that action at this time.
0 commit comments