Get MH Assets

node v18.11.0
version: 1.0.0
endpointsharetweet
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-await-in-loop */ /* eslint-disable no-console */ const fetch = require('isomorphic-fetch'); async function getAssetsCount(universeId) { const getAssetsCountQuery = ` query($universeId: Int!) { allAssets(condition: {universeId:$universeId} ) { totalCount } } `; const response = await fetch(process.env.PROD_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: getAssetsCountQuery, variables: { universeId, }, }), }); const result = await response.json(); const data = result.data.allAssets; return data === null ? 0 : data.totalCount; } const run = async () => { const count = await getAssetsCount(parseInt(process.env.MH_UNIVERSE_ID)); console.log(`#assets in MH: ${count}`); }; run();
Loading…

no comments

    sign in to comment