# How is a fetch of a cURL used?

**URL:** <https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354>\
**Category:** Ask for Help\
**Created:** [March 19, 2023, 10:24am UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354 "2023-03-19T10:24:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 19, 2023, 10:24am UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/1 "2023-03-19T10:24:43Z")

</div>

Greetings to the whole community. I have a question to ask: until now, when using a query of a json file, I had a canonical URL. This time, however, I get a cURL that works fine, but when converted to a URL, it no longer works.  
The cURL is as follows: curl -X GET “[https://domustudioapi.danea.it/api/external/condominio](https://domustudioapi.danea.it/api/external/condominio)” -H “accept: application/json” -H “x-api-version: 1.0” -H “X-DANEA-API-KEY: 7011819a-fb58-4ede-8cec-xxxxxxx”  
The converted url, on the other hand, which I tried to use, is as follows: [https://domustudioapi.danea.it/api/external/condominio?accept=application/json&x-api-version=1.0&X-DANEA-API-KEY=7011819a-fb58-4ede-8cec-xxxxxxxxxx](https://domustudioapi.danea.it/api/external/condominio?accept=application/json&x-api-version=1.0&X-DANEA-API-KEY=7011819a-fb58-4ede-8cec-xxxxxxxxxx)  
I’m starting to get a bit desperate 🙂  
I could convert it to Javascript, but then I wouldn’t know how to use it. There is surely someone better versed in this kind of situation than I am. Thanks!

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [March 19, 2023, 3:13pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/2 "2023-03-19T15:13:31Z")

</div>

> [@profxeni](#):
>
> [https://domustudioapi.danea.it/api/external/condominio?accept=application/json&x-api-version=1.0&X-DANEA-API-KEY=7011819a-fb58-4ede-8cec-xxxxxxxxxx](https://domustudioapi.danea.it/api/external/condominio?accept=application/json&x-api-version=1.0&X-DANEA-API-KEY=7011819a-fb58-4ede-8cec-xxxxxxxxxx)

Hola!

Your cURL command should look like…

```auto
curl -X GET "https://domustudioapi.danea.it/api/external/condominio"   
-H "accept: application/json"    
-H "x-api-version: 1.0"    
-H "X-DANEA-API-KEY: 7011819a-fb58-4ede-8cec-xxxxxxx"  

```

If we use a Javascript code, this should be:

```auto
const url = 'https://domustudioapi.danea.it/api/external/condominio';

const response = await fetch(url, {
    headers: {
        'accept': 'application/json',
        'x-api-version': '1.0',
        'X-DANEA-API-KEY': '7011819a-fb58-4ede-8cec-xxxxxxx',
    },
});

const json = await response.text(); // or response.json();
return json 

```

Try this code on your Page using a valid API key and let me know the results please. The web site _[https://domustudioapi.danea.it](https://domustudioapi.danea.it)_ is working fine btw?

Saludos!

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 20, 2023, 1:54pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/3 "2023-03-20T13:54:12Z")

</div>

Thank you @gvalero for your reply. The Javascript code does not give me an error. The keys I have exposed are clearly fictitious. Once they are entered into the column correctly, the system does a check and expects more data, which are p1, p2…  
At this point I would like to understand what to enter. I thank in advance anyone who would like to engage in this arduous explanation 🙂

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 20, 2023, 2:33pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/4 "2023-03-20T14:33:43Z")

</div>

> [@profxeni](#):
>
> Once they are entered into the column correctly, the system does a check and expects more data, which are p1, p2…

What do you mean by this? The javascript column allows for 3 parameters. Those 3 parameters are always there. You can do anything you want with them if your code requires parameters to pass in data from other columns. However, you are not required to use them if you don’t need them.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [March 20, 2023, 2:48pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/5 "2023-03-20T14:48:08Z")

</div>

Hola de nuevo!

Just replace/use a valid API key in this line and let us know results you get.

```auto
'X-DANEA-API-KEY': '7011819a-fb58-4ede-8cec-xxxxxxx',

```

_p1_ and _p2_ are parameters but in this specific case, you don’t need to use them so far

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 20, 2023, 5:12pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/6 "2023-03-20T17:12:22Z")

</div>

Unfortunately, it gives me an error:  
Function Error  
TypeError: Failed to fetch  
I have entered the correct API key and no parameters.  
The cURL works.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [March 20, 2023, 6:11pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/7 "2023-03-20T18:11:18Z")

</div>

Uuummm… 🙄

Don’t you have a CORS problem similar to the one you had a while back here:?

> [@Google maps distance matrix](https://community.glideapps.com/t/google-maps-distance-matrix/42198):
>
> Greetings to all. I was experimenting with a new feature for my web app that would show me the actual mileage and travel time, from an origin point to a destination point. The origin of the example is: [https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m\_PQ](https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m_PQ) I then inserted the Google URL into a column with a template (see image), taking the start and end path data from two other columns. Fi…

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 21, 2023, 4:54pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/8 "2023-03-21T16:54:01Z")

</div>

I don’t think so. If I try it directly in a windows CMD shell, it works. I instantly display a wonderful JSON.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 21, 2023, 5:24pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/9 "2023-03-21T17:24:32Z")

</div>

In simple terms, CORS means you are trying to access a URL via another URL. That’s different from directly accessing the destination URL directly as you are with the CMD shell. It’s a browser security feature to help prevent a website from stealing information from another website. Some websites allow CORS and some don’t.

A server backend can access data protected by CORS whereas a website cannot indirectly access that same data. Since a javascript column runs directly within a Glide App (as a middle man between the end user and the destination URL, and not directly on glide servers), then it is subject to the CORS policy.

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 21, 2023, 6:04pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/10 "2023-03-21T18:04:40Z")

</div>

It could be. So there is no way to use this API?

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [March 21, 2023, 6:21pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/11 "2023-03-21T18:21:52Z")

</div>

If you have a CORS problem, your plan B is to use a CORS proxy to avoid this problem, but you should pay attention to security:

> **[What are CORS proxies, and when are they safe?](https://httptoolkit.com/blog/cors-proxies/)**
>
> CORS can be complicated. If you're struggling with it, you might discover the concept of a 'CORS proxy' that promises to solve this, like…

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [March 24, 2023, 1:23pm UTC](https://community.glideapps.com/t/how-is-a-fetch-of-a-curl-used/59354/12 "2023-03-24T13:23:10Z")

</div>

Greetings to all. I managed to solve this long-standing problem by getting help from a Google Sheet plugin I was already using successfully for weather: mixedanalytics API connector.  
With this fantastic help, I managed to import the cURL and after very little work on the data to be extracted, by the way also in a visual way without any code, boom… it extracted all the data I needed in the Google sheet. I hope it will be useful to other friends in this community as well.
