Store contract results tag in a variable

0 votes

I have a web3 contstant look like this.

const test = contract_instance.methods.getPost(15).call().then(console.log);

This returns results like this.

Result {
  '0': '2017-08-28',
  '1': '19:18:04.986593',
  '2': '07:17:00',
  '3': '11112323',
  '4': '12',
  date: '2017-08-28',
  login_time: '19:18:04.986593',
  logout_time: '07:17:00',
  login_device_id: '11112323',
  user_id: '12' }

Now when i want to console single tag through console.log(test[0]); this returns undefined My approach is to store every result tag in its individual variable. Need some suggestion.

Oct 9, 2018 in Blockchain by digger
• 27,620 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

then() takes a function as argument that is called on fulfillment of the promise. You can then add the value to an array for example:

var results = []

results[0] would then be the result object you are looking for and results[0]['0'] would give you the date '2017-08-28' for example.

answered Oct 9, 2018 by Omkar
• 65,810 points

Related Questions In Blockchain

0 votes
1 answer

Unable to change a state variable in a contract

I am assuming that the issue is ...READ MORE

answered Oct 29, 2018 in Blockchain by Christine
• 15,790 points
+1 vote
1 answer

Is it possible to store blockchain in a sql or no-sql database?

Currently, following are the options to store ...READ MORE

answered Apr 20, 2018 in Blockchain by Perry
• 16,450 points

edited Aug 9, 2018 by Omkar 41 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
+1 vote
2 answers

Can I include real world data in a smart contract? If so, how?

You cant access/embed real world data using ...READ MORE

answered Jul 17, 2018 in Blockchain by sapan
0 votes
1 answer

Not able to invoke a contract in Ethereum Private chain using geth

Hope this helps: contract mortal { /* ...READ MORE

answered Oct 22, 2018 in Blockchain by Omkar
• 65,810 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.