# How can I get a json file hosted on the IC with JS in the browser? \[Anonymous Dev Question\]

**URL:** <https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094>\
**Category:** Developers\
**Created:** [January 20, 2023, 10:43pm UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094 "2023-01-20T22:43:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diegop](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/diegop/32/569_2.png) [@diegop](https://forum.dfinity.org/u/diegop)\
**Post date:** [January 20, 2023, 10:43pm UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094/1 "2023-01-20T22:43:18Z")

</div>

# My Intent

Ahoy ICP devs!

Within the internal DFINITY team channels (OpenChat, Signal, Slack), I have seen some developer-centric technical questions which I think would be great for the wider developer forum to see. I think they can be helpful to share the question/answer so future folks looking for answers can find them.

This is my first attempt at doing this, and if people do not find it useful, I will stop 🙂

Let me know what you think. Thanks!

# Question

_How can I get a json file hosted on the IC with JS in the browser?_

_`fetch` isn’t working because I get CORS issues. Can they be set in the canister? Or should I use agent-js somehow? I believe it’s a normal CORS issue, but with IC maybe I’m missing something 😅_

_Thanks!_

## Answer

_you can configure the asset canister to return custom headers, i.e., you can configure_

> \*Access-Control-Allow-Origin: \*\*

_there and you should be able to fetch it from a different origin._

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [January 20, 2023, 11:11pm UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094/2 "2023-01-20T23:11:36Z")

</div>

Configure it where? I didn’t know there was a config file for the standard Asset canister.

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [January 21, 2023, 6:26am UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094/3 "2023-01-21T06:26:46Z")

</div>

[`.ic-assets.json`](https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/#new-feature-support-for-configuring-assets-in-assets-canister)

---

<div class="post-metadata">

**Author:** ![blabagastered](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/blabagastered/32/8592_2.png) [@blabagastered](https://forum.dfinity.org/u/blabagastered)\
**Post date:** [January 22, 2023, 6:52pm UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094/4 "2023-01-22T18:52:39Z")

</div>

Ideally everyone asks all technical questions in the open forum, so that their answers are also searchable and in the open forum.

Anonymous posting can probably be enabled if necessary.

---

<div class="post-metadata">

**Author:** ![diegop](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/diegop/32/569_2.png) [@diegop](https://forum.dfinity.org/u/diegop)\
**Post date:** [January 23, 2023, 6:23pm UTC](https://forum.dfinity.org/t/how-can-i-get-a-json-file-hosted-on-the-ic-with-js-in-the-browser-anonymous-dev-question/18094/5 "2023-01-23T18:23:23Z")

</div>

> [@blabagastered](#):
>
> Ideally everyone asks all technical questions in the open forum, so that their answers are also searchable and in the open forum.

I agree.

I do think its reasonable people post things in internal channels because they expect faster reply, but I think moving more and more openly is good.

> [@blabagastered](#):
>
> Anonymous posting can probably be enabled if necessary.

To be honest, I anonymized the question for non-obvious reason:

1. I removed information about the problem that I thought the original author may not want in a public format.

2. I anomymized also because I see a whole lot of internal slack questions which i think would help to be public, and anomyzing would make it easier to get the blessing to post it. I want to do LOTS more.
