Using Client and Arc to retrieve proposal's data

Hello
I need to get the title of a proposal using Client. I can find the id using Arc, but no other info are shown. Using subgraph I can see all proposal’s properties, but no way to do the same in .js.

          {
            "contributionReward": {
              "beneficiary": "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1",
              "id": "0x5bc9c138648ad56bb2d57bae425faa3fd4a07f0bd4bf422d1711ee8006f08cba"
            },
            "expiresInQueueAt": "1573669736",
            "genesisProtocolParams": {
              "boostedVotePeriodLimit": "86400",
              "id": "0xb16ee58375cf1e09475bfc967653dd7a458df4bc0a0cab9e488b03809df8134a"
            },
            "id": "0x5bc9c138648ad56bb2d57bae425faa3fd4a07f0bd4bf422d1711ee8006f08cba",
            "stakesAgainst": "150000000000000000000",
            "title": "Sample Proposal3",
            "votesAgainst": "247500000000000000000",
            "votesFor": "0"
          },

Is there any document you can share with me that explain in detail how to do queries?

Thanks

Daniele

1 Like

Hi Daniele, thanks for the question.

The readme file int he client library contains some links to further documentation; in particular you may be interested in https://github.com/daostack/client/blob/master/documentation/demo.js, which contains a practical example of querying.

let me know if you get stuck or have more questions. (I know, we should update our docs :-))

1 Like

Hi
I’ve read that demo and it was very useful to start playing with client! What i’ve tried to do is to obtain the title of the proposal in App.js of starter-template example. I’ve managed to obtain it in componentWillMount, but the problem is in rendering. I want to display the title of proposal, not the id, but the client has only id and I have to query Client, all with async functions that don’t work in render. Is there a way to have all proposal’s field in the object returned from Client? There are best practices on how to retrieve all properties? This is my code in componentWillMount:

    const all_proposals = await dao.proposals().first()
    const prop = await Proposal.search(arc, {where: {id: '<proposal_id>'}}).first()
    const proposalState = await prop.state().first()
    console.log (proposalState.title)

Thanks

Daniele

Hi Daniele!

You might find this document useful. What you are looking for is to subscribe the proposal.state().

Feel free to give feedback on the docs and ask questions if you still have any.

Hi
Subscription solved my problem. Thanks!