# Agent.query in react native not fetching properly

**URL:** <https://forum.dfinity.org/t/agent-query-in-react-native-not-fetching-properly/5990>\
**Category:** Developers\
**Created:** [July 19, 2021, 6:15pm UTC](https://forum.dfinity.org/t/agent-query-in-react-native-not-fetching-properly/5990 "2021-07-19T18:15:46Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [July 21, 2021, 8:38pm UTC](https://forum.dfinity.org/t/agent-query-in-react-native-not-fetching-properly/5990/5 "2021-07-21T20:38:53Z")

</div>

So the first step obviously is to apply the polyfill globally using:

```auto
import {polyfill as polyfillFetch} from 'react-native-polyfill-globals/src/fetch'
polyfillFetch();

```

I put this in a `shim.js` that is imported by the top-level `index.js`.

* * *

The second step is to patch `@dfinity/agent` to replace this [line](https://github.com/dfinity/agent-js/blob/579f8aa3fae946a9060bed39ff56c87151098c49/packages/agent/src/agent/http/index.ts#L204) with:

```auto
this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign({reactNative: {textStreaming: true}}, transformedRequest.request), { body })),

```

Note that `{reactNative: {textStreaming: true}}` was added.

* * *

The last step is to patch `react-native-fetch-api` and replace the “blob” in this [line](https://github.com/react-native-community/fetch/blob/74f6a96ba1d720e6effd42ee9a47655b44ec9e3b/src/Fetch.js#L34) with “base64”.

* * *

Let me know if this works.

---

_[View the full topic](https://forum.dfinity.org/t/agent-query-in-react-native-not-fetching-properly/5990)._
