2

This question already has an answer here:

I've been using web3.js to facilitate the creation of a decentralized app. A major problem I've run into is the lack of support that the web3.js has for supporting a 'struct'. As a C++ developer, I'm at a bit at a loss of how I should continue..

For example:

    struct Pet {
    address owner;
    uint256 price;
}


    function getAdopters() public view returns (Pet[16]) {
    return pets;
}

Gives me nothing useful. I would appreciate any guidance on how to solve this problem.

And in app.js

 markAdopted: function(adopters, account) {
var adoptionInstance;

App.contracts.Adoption.deployed().then(function(instance) {
  adoptionInstance = instance;

  return adoptionInstance.getAdopters.call();
}).then(function(adopters) {
  for (i = 0; i < adopters.length; i++) {
    if (adopters[i] !== '0x0000000000000000000000000000000000000000') {
        $('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);
        var loc = document.getElementById('owned-by');
        loc.innerHTML += adopters[i];

    }
  }
}).catch(function(err) {
  console.log(err.message);
});

},

Which throws the following error in the Chrome console:

invalid solidity type!: tuple[16]

marked as duplicate by Ismael, flygoing, Community Feb 18 '18 at 7:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.