Skip to content

Commit

Permalink
Convert try/catch to then/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyandreevsky committed Mar 14, 2024
1 parent 53cab55 commit 83603bd
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 78 deletions.
16 changes: 9 additions & 7 deletions packages/frontend/src/app/block/[hash]/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ function Block({ hash }) {
const fetchData = () => {
setLoading(true)

try {
Api.getBlockByHash(hash).then((res) => {
Api.getBlockByHash(hash).then((res) => {

setBlock(res)
setLoading(false)
setBlock(res)

}).catch((error)=>{

})
} catch (error) {
console.log(error)
}

}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [hash])
Expand Down
21 changes: 12 additions & 9 deletions packages/frontend/src/app/blocks/Blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,21 @@ function Blocks() {

const fetchData = () => {
setLoading(true)
try {
loader().then((res) => {

loader().then((res) => {

setBlocks(res.blocks)
setTotal(res.total)

setBlocks(res.blocks)
setTotal(res.total)
setLoading(false)
}).catch((error)=>{

})
} catch (error) {
console.log(error)
}


}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ function DataContract({identifier}) {
const fetchData = () => {
setLoading(true)

try {
loader(identifier).then((res) => {
loader(identifier).then((res) => {

setDataContract(res.dataContract)
setDocuments(res.documents.resultSet)
setPageCount(Math.ceil(res.documents.pagination.total / pagintationConfig.itemsOnPage.default))
setLoading(false)
setDataContract(res.dataContract)
setDocuments(res.documents.resultSet)
setPageCount(Math.ceil(res.documents.pagination.total / pagintationConfig.itemsOnPage.default))

}).catch((error) => {

})
} catch (error) {
console.log(error)
}

}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [identifier])
Expand Down
17 changes: 10 additions & 7 deletions packages/frontend/src/app/dataContracts/DataContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ function DataContractsLayout() {
const fetchData = () => {
setLoading(true)

try {
Api.getDataContracts(1, 30).then((res) => {
Api.getDataContracts(1, 30).then((res) => {

setDataContracts(res.resultSet)
setLoading(false)
setDataContracts(res.resultSet)

}).catch((error) => {

})
} catch(error) {
console.log(error)
}

}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [])
Expand Down
18 changes: 10 additions & 8 deletions packages/frontend/src/app/document/[identifier]/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ function Document({identifier}) {
const fetchData = () => {
setLoading(true)

try {
Api.getDocumentByIdentifier(identifier).then((res) => {
Api.getDocumentByIdentifier(identifier).then((res) => {

setDocument(res)
setLoading(false)
setDocument(res)

})
} catch (error) {
}).catch ((error) => {
console.log(error)
}


}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [identifier])
Expand Down
20 changes: 11 additions & 9 deletions packages/frontend/src/app/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ function Home() {
const fetchData = () => {
setLoading(true)

try {
loader().then((res) => {
loader().then((res) => {

setStatus(res.status)
setTransactions(res.transactions)
setLoading(false)
setStatus(res.status)
setTransactions(res.transactions)

}).catch((error) => {

})
} catch(error) {
console.log(error)
}


}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [])
Expand Down
16 changes: 9 additions & 7 deletions packages/frontend/src/app/identities/Identities.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ function Identities() {
const fetchData = () => {
setLoading(true)

try {
Api.getIdentities().then((identities) => {
Api.getIdentities().then((identities) => {

setIdentities(identities.resultSet)
setLoading(false)
setIdentities(identities.resultSet)

}).catch((error) => {

})
} catch(error) {
console.log(error)
}

}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [])
Expand Down
28 changes: 15 additions & 13 deletions packages/frontend/src/app/identity/[identifier]/Identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ function Identity({identifier}) {
const fetchData = () => {
setLoading(true)

try {
loader(identifier).then((res) => {

setIdentity(res.identity)
setDataContracts(res.dataContracts)
setDocuments(res.documents)
setTransactions(res.transactions)
setTransfers(res.transfers)
setLoading(false)

})
} catch (error) {
loader(identifier).then((res) => {

setIdentity(res.identity)
setDataContracts(res.dataContracts)
setDocuments(res.documents)
setTransactions(res.transactions)
setTransfers(res.transfers)

}).catch((error) => {

console.log(error)
}

}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [identifier])
Expand Down
20 changes: 11 additions & 9 deletions packages/frontend/src/app/transaction/[hash]/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,20 @@ function Transaction({hash}) {
const fetchData = () => {
setLoading(true)

try {
loader(hash).then((res) => {
loader(hash).then((res) => {

setTransaction(res.transaction)
decodeTx(res.transaction.data)
setLoading(false)
setTransaction(res.transaction)
decodeTx(res.transaction.data)

}).catch((error) => {

})
} catch (error) {
console.log(error)
}


}).finally(() => {

setLoading(false)

})
}

useEffect(fetchData, [hash])
Expand Down

0 comments on commit 83603bd

Please sign in to comment.