# JSON javascript fetch response to my column using QueryJson

**URL:** <https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404>\
**Category:** Ask for Help\
**Tags:** custom-code\
**Created:** [January 22, 2025, 7:43am UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404 "2025-01-22T07:43:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Romieux](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/_romieux/32/83089_2.png) [@\_Romieux](https://community.glideapps.com/u/_Romieux)\
**Post date:** [January 22, 2025, 7:43am UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/1 "2025-01-22T07:43:47Z")

</div>

Hi,  
Can someone help me to parse a Json response from a Javascript fetch column (using await fetch). I can see the response only in chrome but not at the Javascript column that send request. The response are ok and Json. After copy&paste the response in a Text column and get with QueryJson. It’s works, but I can’t make it direct from Javascript column.

Javascript Column \> QueryJson column not working (but response in chrome nav are there)  
Javascript Column \> Text Column manually \> QueryJson is OK  
Thanks

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [January 22, 2025, 11:40am UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/2 "2025-01-22T11:40:39Z")

</div>

Can you show me what you got in your js column?

---

<div class="post-metadata">

**Author:** ![\_Romieux](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/_romieux/32/83089_2.png) [@\_Romieux](https://community.glideapps.com/u/_Romieux)\
**Post date:** [January 22, 2025, 12:38pm UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/3 "2025-01-22T12:38:02Z")

</div>

```auto
const PAT = ‘KEY’;
const USER_ID = ' i';       
const APP_ID = 'main';
const MODEL_ID = 'item-v1';
const MODEL_VERSION_ID = '';    
const IMAGE_URL = 'https://samples.jpg';

const raw = JSON.stringify({
    "user_app_id": {
        "user_id": USER_ID,
        "app_id": APP_ID
    },
    "inputs": [
        {
            "data": {
                "image": {
                    "url": IMAGE_URL
                }
            }
        }
    ]
});
const requestOptions = {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Authorization': 'Key ' + PAT
    },
    body: raw
};
await fetch("https://model.com/v2/models/" + MODEL_ID + "/versions/" + MODEL_VERSION_ID + "/outputs", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

```

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [January 22, 2025, 2:06pm UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/4 "2025-01-22T14:06:38Z")

</div>

> [@\_Romieux](#):
>
> ```auto
> await fetch("https://model.com/v2/models/" + MODEL_ID + "/versions/" + MODEL_VERSION_ID + "/outputs", requestOptions)
> .then(response => response.text())
> .then(result => console.log(result))
> .catch(error => console.log('error', error));
> 
> ```

Change this to this:

```js
try {
const res = await fetch("https://model.com/v2/models/" + MODEL_ID + "/versions/" + MODEL_VERSION_ID + "/outputs", requestOptions);
const data = await res.text();
return data;
}
catch(e) {
return `Error Message you want! You can also add error message and stack trace: ${e.stackTrace}`;
}

```

---

<div class="post-metadata">

**Author:** ![\_Romieux](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/_romieux/32/83089_2.png) [@\_Romieux](https://community.glideapps.com/u/_Romieux)\
**Post date:** [January 22, 2025, 2:27pm UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/5 "2025-01-22T14:27:40Z")

</div>

Now is passing data to the Javascript column but I have a new problem with CORS backside during the post event, It’s not accepting my request or response. He demand use a CORS ?  
I tested with ‘Access-Control-Allow-Origin’ : ‘\*’ but nothing always is blocking

---

<div class="post-metadata">

**Author:** ![MaximeBaker](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maximebaker/32/80877_2.png) [@MaximeBaker](https://community.glideapps.com/u/MaximeBaker)\
**Post date:** [January 22, 2025, 11:13pm UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/6 "2025-01-22T23:13:41Z")

</div>

By the way 2 questions:

Did you try with Call API action?

Is the PAT key Private or have a lot of access to your [model.com](http://model.com)’s account? I am asking that because if it is, you are exposing it by using front end code (JavaScript). The Call API action store the secret in the back-end.

---

<div class="post-metadata">

**Author:** ![\_Romieux](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/_romieux/32/83089_2.png) [@\_Romieux](https://community.glideapps.com/u/_Romieux)\
**Post date:** [January 23, 2025, 10:36am UTC](https://community.glideapps.com/t/json-javascript-fetch-response-to-my-column-using-queryjson/79404/7 "2025-01-23T10:36:33Z")

</div>

Hi,  
I understand the limitations but I’m not very rich at the moment to try others methods, I need call APIs with the poor method. May be others methods exist but I have some limitations to discovers quickly (virtual machines, personal cloud or vps). I would prefer a pay option based on a counter like others.

I recognize the limitations, but I’m currently not in a financial position to explore other methods. I need to use APIs with the limited option available. While there may be other methods, my ability to discover them is restricted (virtual machines, personal clouds, or VPS). I would prefer a paid option based on usage, similar to others inclued in free testing package. Regards

CORS, I can use external cors web pages but exist some way to fix in my javascript code that works ? Thanks
