Skip to content

Commit 6cebc00

Browse files
authored
Merge pull request #185 from docknetwork/feat/ecosystem-tools
feat: separate ecosystem fetch from hook
2 parents 1451f7f + f76c9db commit 6cebc00

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/react-native/lib/credentials/credentialHooks.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,20 @@ export function useGetCredentialStatus({ credential }) {
183183
}, [status]);
184184
}
185185

186+
export async function getIssuerEcosystems(issuer, isTestMode = false) {
187+
const API = isTestMode ? "https://api-testnet.dock.io" : "https://api.dock.io";
188+
//TODO: Temporary implementation - Replace API fetch with sdk when sdk implementation
189+
const response = axios.get(`${API}/dids/${issuer.id}/ecosystems`);
190+
return (await response).data?.list
191+
}
192+
186193
export function useEcosystems({ issuer }) {
187194
const { testMode } = useWallet();
188195
const [ecosystems, setEcosystems] = useState([]);
189196

190-
const API = testMode ? "https://api-testnet.dock.io" : "https://api.dock.io";
191197
useEffect(() => {
192-
//TODO: Temporary implementation - Replace API fetch with sdk when sdk implementation
193-
axios.get(`${API}/dids/${issuer.id}/ecosystems`).then(result => {
194-
setEcosystems(result.data?.list || []);
198+
getIssuerEcosystems(issuer, testMode).then(ecosystems => {
199+
setEcosystems(ecosystems || []);
195200
})
196201
}, [issuer.id]);
197202

0 commit comments

Comments
 (0)