Check a mosaic balance using JavaScript SDK

Hi, I just created a mosaic in testnet and send few of it to another account. However, when I check using nem.com.requests.account.mosaics.owned and nem.com.requests.account,mosaics.allDefinitions only xem appeared.

The SDK that im using is NEM-sdk. Is there other way to check mosaic balance?

3 Likes

This is what I basically just did:

    nem.com.requests.account.mosaics.owned(endpoint, parsed.address).then(function(res) {
        console.log(res);
        finalArray.mosaics = res;
        response = { "statusCode": 200, "body": JSON.stringify((finalArray))};

    }).catch(function(err) {
        console.error(err);
        response = {
            "isBase64Encoded": "false",
            "statusCode": "500",
            "body": JSON.stringify((err))
        };
    });

It returns:

"mosaics": {
    "data": [
      {
        "quantity": 845650000,
        "mosaicId": {
          "namespaceId": "nem",
          "name": "xem"
        }
      },
      {
        "quantity": 10000000000,
        "mosaicId": {
          "namespaceId": "locationcore",
          "name": "lcc"
        }
      }
    ]
  }
1 Like