From 1369d8984e66fe6a1bf536657db403673fccb55f Mon Sep 17 00:00:00 2001 From: Tushar Ojha Date: Tue, 3 Jan 2023 17:37:24 +0530 Subject: [PATCH] fixed api null check issue --- template/src/App.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/template/src/App.tsx b/template/src/App.tsx index d4ed6f3..63d4a54 100644 --- a/template/src/App.tsx +++ b/template/src/App.tsx @@ -41,12 +41,12 @@ export default function App() { setSpace(undefined) return } - if (!isReady) { + if (!isReady || !api) { console.log({ message: 'Unable to connect to the API.' }) return } const spaceId = '1005' - const res = await api!.findSpace({ id: spaceId }) + const res = await api.findSpace({ id: spaceId }) setSpace(res) console.log(res) } @@ -56,7 +56,7 @@ export default function App() { setSpace(undefined) // Always assure, the [api] is not null using [isReady] property. - if (!isReady) { + if (!isReady || !api) { console.log({ message: 'Unable to connect to the API.' }) return } @@ -73,14 +73,14 @@ export default function App() { // // To change the IPFS either pass [CustomNetwork] or call [setupCrustIPFS] with // your mnemonic (MAKE SURE TO HIDE MNEOMIC BEFORE UPLOADING TO PUBLIC NETWORK). - const cid = await api!.ipfs.saveContent({ + const cid = await api.ipfs.saveContent({ about: 'Subsocial is an open protocol for decentralized social networks and marketplaces. It`s built with Substrate and IPFS', image: null, name: 'Subsocial', tags: ['subsocial'], }) - const substrateApi = await api!.blockchain.api + const substrateApi = await api.blockchain.api const spaceTransaction = substrateApi.tx.spaces.createSpace( IpfsContent(cid),