# Agent.query QueryFields example

**URL:** <https://forum.dfinity.org/t/agent-query-queryfields-example/5769>\
**Category:** Developers\
**Created:** [July 7, 2021, 4:59pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769 "2021-07-07T16:59:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [July 7, 2021, 4:59pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769/1 "2021-07-07T16:59:58Z")

</div>

Hi

I am trying to use agent.query to query a canister from typescript front-end in react native. I could not find any example of how it should be. Any help is much appreciated.  
This is what I am trying to achieve: call test method of a canister from front-end using Http call. Specifically instead of ??? in the code below, I am not sure what to put as a valid QueryFields.

```auto
const authClient = await AuthClient.create();
    const identity = authClient.getIdentity();
    const agent = new HttpAgent({
        host: 'https://boundary.ic0.app/',
        identity,
    });
    
    const canisterId = Principal.fromText('4k2wq-cqaaa-aaaab-qac7q-cai');
    agent.query(canisterId, <????????>, identity, ).then((res)=>{
        console.log(res);
    })

```

---

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [July 7, 2021, 5:10pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769/2 "2021-07-07T17:10:00Z")

</div>

to be more specific, I am having problem understandign arg parameter in queryFields

```auto
const queryData = {
        methodName: 'greet',
        arg: ??? how to build this?
}

```

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 7, 2021, 5:19pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769/3 "2021-07-07T17:19:21Z")

</div>

Does your canister have a candid interface? The pattern we tend to use is to generate javascript declaration files from the `.did` file, which we then use with an abstraction of `@dfinity/agent -Actor.createActor()` so you don’t need to write the query manually

---

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [July 7, 2021, 5:22pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769/4 "2021-07-07T17:22:07Z")

</div>

> [@anon74414410](#):
>
> o you don’t need to write the query m

yes I understand that approach, but wanted to see if there is a way to go directly with Http request approach? and if yes, how

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 7, 2021, 5:30pm UTC](https://forum.dfinity.org/t/agent-query-queryfields-example/5769/5 "2021-07-07T17:30:52Z")

</div>

It’s hard to answer in the abstract. You can inspect the [source code of agent](https://github.com/dfinity/agent-js/blob/main/packages/agent/), or if you provide the interface you’re targeting I might be able to assemble it for you
