Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return array in methods.myMethod.call #2449

Closed
webersson opened this issue Mar 4, 2019 · 3 comments
Closed

Return array in methods.myMethod.call #2449

webersson opened this issue Mar 4, 2019 · 3 comments
Labels
Bug Addressing a bug

Comments

@webersson
Copy link

webersson commented Mar 4, 2019

Expected behavior

I'm trying to get an array of Numbers from this function:

function getTimes() public view returns (uint[] memory) {
    return times;
}

...Calling the function via web3 like this:

ContractInstance.methods.getTimes().call().then(result => {
    console.log(result);        
})

..my output is a comma separeted string: 1551744000,1551657600
In order to get an array of Numbers I have to modify the String like this:

var array = result.split(',').map(str => {return Number(str)})

Now I'm getting the required array of Numbers:

[1551744000,1551657600]

I'm asking myself if this is the right way. Am I missing something? Thanks for any help.

Versions

solidity: ^0.5.0;
web3: 1.0.0-beta.47

@nivida
Copy link
Contributor

nivida commented Mar 4, 2019

Thanks for creating this issue! Could you please add the version of Web3.js you are using?

@webersson
Copy link
Author

Yes, of course. I'm using solidity: ^0.5.0 and web3: 1.0.0-beta.47

@nivida nivida added Needs Clarification Requires additional input and removed more information needed labels Mar 5, 2019
@webersson
Copy link
Author

Just found out, the issue does not consist with web3@1.0.0-beta.44.

@nivida nivida added the In Progress Currently being worked on label Mar 5, 2019
@nivida nivida added Bug Addressing a bug and removed Needs Clarification Requires additional input In Progress Currently being worked on labels Mar 5, 2019
@nivida nivida closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

2 participants