# POST to API

**URL:** <https://community.glideapps.com/t/post-to-api/38715>\
**Category:** Ask for Help\
**Created:** [February 19, 2022, 7:41pm UTC](https://community.glideapps.com/t/post-to-api/38715 "2022-02-19T19:41:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Crossley](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adam_crossley/32/24083_2.png) [@Adam\_Crossley](https://community.glideapps.com/u/Adam_Crossley)\
**Post date:** [February 19, 2022, 7:41pm UTC](https://community.glideapps.com/t/post-to-api/38715/1 "2022-02-19T19:41:26Z")

</div>

Just going around in circles trying to understand how to use the fetch JSON column to make a POST request to an API.

I struggle a lot with the syntax, and to be honest I don’t even know if it’s possible. But does anybody know what I need to do to get this test example from the API docs to work?

```auto
curl --location --request POST 'https://api.dibsy.one/v1/payments' \
--header 'Authorization: Bearer sk_test_42069ce69ea8686921f128be69d65ddf9706' \
--header 'Content-Type: application/json' \
--data-raw '{
   "description":"Gold Style Watch - Special Edition",
   "amount":56.99,
   "metadata":{
      "product_id":156,
      "customer_id":345
   },
   "customer":{
      "name":"John Doe",
      "email":"your_customer@email.com",
      "phone":"+97433333333"
   },
   "redirectUrl":"https://example.com/order"
}'

```

Here are the docs:

[https://docs.dibsy.one/api-reference/payments-api/create-payments](https://docs.dibsy.one/api-reference/payments-api/create-payments)

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)\
**Post date:** [February 19, 2022, 8:06pm UTC](https://community.glideapps.com/t/post-to-api/38715/2 "2022-02-19T20:06:14Z")

</div>

The Fetch JSON column uses a `GET` request, and cannot use Bearer-style authorization.

This column can also be called arbitrarily often and repeatedly, so it’s not safe to use it to trigger actions like making payments.

The Webhook action can make POST requests.

---

<div class="post-metadata">

**Author:** ![Adam\_Crossley](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adam_crossley/32/24083_2.png) [@Adam\_Crossley](https://community.glideapps.com/u/Adam_Crossley)\
**Post date:** [February 19, 2022, 8:21pm UTC](https://community.glideapps.com/t/post-to-api/38715/3 "2022-02-19T20:21:38Z")

</div>

Fair enough!

I use A LOT of webhooks to do things with Integromat.

But using that API docs example POST request, how would I dial that into the webhook action so that it posts straight to the Dibsy API?

---

<div class="post-metadata">

**Author:** ![11183](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/11183/32/29797_2.png) [@11183](https://community.glideapps.com/u/11183)\
**Post date:** [February 19, 2022, 8:33pm UTC](https://community.glideapps.com/t/post-to-api/38715/4 "2022-02-19T20:33:57Z")

</div>

There’s HTTP module in Integromat. It can make POST requests. So you could first send a webhook from Glide to Integromat and then use HTTP module to make request to the API you want.

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [February 19, 2022, 8:40pm UTC](https://community.glideapps.com/t/post-to-api/38715/5 "2022-02-19T20:40:08Z")

</div>

This 👆

---

<div class="post-metadata">

**Author:** ![Adam\_Crossley](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/adam_crossley/32/24083_2.png) [@Adam\_Crossley](https://community.glideapps.com/u/Adam_Crossley)\
**Post date:** [February 19, 2022, 8:48pm UTC](https://community.glideapps.com/t/post-to-api/38715/6 "2022-02-19T20:48:12Z")

</div>

I’m aware of that, I was thinking it was possible to do it from Glide to cut out the middle-man. Nevermind, back to plan B!

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [February 19, 2022, 9:05pm UTC](https://community.glideapps.com/t/post-to-api/38715/7 "2022-02-19T21:05:33Z")

</div>

you can do it in Google scripts… and use webhook to update a sheet that is connected to your Glide App:

[![PP avatar background](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/4/249681ab5b0c75f77cb138dec0a284695291f6c1.png)](https://paypal-button-demo.glideapp.io/dl/ewAiAHQAIgA6ADAALAAiAHMAIgA6ACIAYwBsAGEAcwBzAC0AUABhAHkAcABhAGwAIgAsACIAcgAiADoAIgBpADAAYgBtAHEALQA3AFYAVABuAGUAdABDAGwANQBiAC4AcwBxAEcAZgBRACIALAAiAG4AIgA6ACIAUABhAHkAUABhAGwAIgB9AA%3D%3D)[![stripe avatar background](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/1/a166b9d2391c15c31a0e27cbe9ad165f17260a60.png)](https://stripe-button-demo.glideapp.io/dl/ewAiAHQAIgA6ADAALAAiAHMAIgA6ACIAYwBsAGEAcwBzAC0AUwB0AHIAaQBwAGUAIABiAHUAeQAgAGIAdQB0AHQAbwBuACIALAAiAHIAIgA6ACIARwBiADgAdwBzAFkAZgBXAFIANABPAGUAOABSADAASwBOAGcAYgBXAGUAZwAiACwAIgBuACIAOgAiAFMAdAByAGkAcABlACAAYgB1AHkAIABiAHUAdAB0AG8AbgAiAH0A)

---

<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:** [August 6, 2022, 11:51pm UTC](https://community.glideapps.com/t/post-to-api/38715/8 "2022-08-06T23:51:44Z")

</div>

Hola @david

Just a couple of technical questions about JavaScript libraries that Glide uses in their plugins: Fetch JSON & JavaScript.

I know we cannot make POST requests by using the Fetch JSON column but our plan B can be a custom JS code and run it via JavaScript plugin. It’s is fine but sometimes I have problems to understand and find the correct syntax within all the JS libraries and flavors available around the world. 🙄

I read time ago that Glide uses _Lodash_ as JS library and also, we can import other [JS libraries](https://community.glideapps.com/t/how-to-import-code-packages-in-the-javascript-column/34466) but I have a doubt about the Fetch() function and the right/best syntax to use.

As you know, _Fetch() API_ supports the **Promise** object and helps a lot to retrieve/handle data and intercept any error during the execution of the request.  
For example, this simple code uses Promise objects:

```auto
fetch('https://yesno.wtf/api') 
  .then(response => response.text())
  .then(result => console.log(result)) 

```

and returns these values using text format (.text()):  
`

> {“answer”:“no”,“forced”:false,“image”:“[https://yesno.wtf/assets/no/1-c7d128c95c1740ec76e120146c870f0b.gif](https://yesno.wtf/assets/no/1-c7d128c95c1740ec76e120146c870f0b.gif)”}

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/9/99ead696c59f3268c0ccae632a362cd203c21bb3.png)

but the above code cannot be used in Glide, the JS plugin doesn’t support it and we must change it using this syntax:

```auto
var Response = await fetch('https://yesno.wtf/api')
const Result= await Response.text();
return Result

```

Glide shows the result like (all is ok)  
…  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/c/3c75b82dc5e952fb5c3408752bca56855e70d56e.png)

As you can imagine, if I try to run my Glide code in other JS editors, nothing works 🤨

So, my questions are:

1. Which JS library can I import into Glide in order to work/use Fetch API’s Promise objects?
2. If I want to use Bearer authorization in Glide’s JavaScript plugin, which JS library do I have to import/use?
3. If I want to test my Glide JS code on other online platforms like [JSFiddle](https://jsfiddle.net/), what language do I have to choose to get right results?. I tested it using “TypeScript” but no luck!

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/e/5e2ae0fa09e05f38fb0ebf78a0f718c3a53fb364.png)

Thanks David, saludos!

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)\
**Post date:** [August 6, 2022, 11:58pm UTC](https://community.glideapps.com/t/post-to-api/38715/9 "2022-08-06T23:58:32Z")

</div>

> [@gvalero](#):
>
> ```auto
> var Response = await fetch('https://yesno.wtf/api')
> const Result= await Response.text();
> return Result
> 
> ```

> **[glide-code-column - JSFiddle - Code Playground](https://jsfiddle.net/xfpjn3rz/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

 ![CleanShot 2022-08-06 at 16.58.11@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/a/dae697376d719bf2db4671c7758c18aaf7a53530.jpeg)

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)\
**Post date:** [August 7, 2022, 12:01am UTC](https://community.glideapps.com/t/post-to-api/38715/10 "2022-08-07T00:01:32Z")

</div>

@gvalero very good start, but it’s clear that you are just starting to learn JavaScript! Please do not mention me for help with code-I do not have time to help you with it. Good luck!

---

<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:** [August 7, 2022, 2:49am UTC](https://community.glideapps.com/t/post-to-api/38715/11 "2022-08-07T02:49:19Z")

</div>

Thanks and sorry for tagging you. I just wanted to know a little more about a point you mentioned earlier.

> The Fetch JSON column uses a `GET` request, and cannot use Bearer-style authorization.

but anyway, I still try to understand all JavaScript flavors when I need to create a bit more complex code and use the correct function. 😇

Taking your example code, this won’t run in Glide JavaScript plugin (I think)

The plugin needs a fetch request with 2 “await” calls, something like this:

```auto
 let response = await fetch(url, options); // resolves with response headers
 let finalResult = await response.json(); // read body as json or text ( .text())
 return finalResult 

```

but, if the code does not use “await” calls (like your example), **no result is shown** in JS column:

```auto
fetch(url, options)
  .then(response => response.json()) // read body as json or text ( .text())
  .then(finalResult => console.log(finalResult));

```

this was my original intention of asking you.  
Why the Glide JavaScript plugin is not able to work with API Fetch without using "await” calls?. Can I import another library to get it?

Sorry again for the inconvenience, felíz noche David!

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david/32/62831_2.png) [@david](https://community.glideapps.com/u/david)\
**Post date:** [August 7, 2022, 3:08am UTC](https://community.glideapps.com/t/post-to-api/38715/12 "2022-08-07T03:08:30Z")

</div>

All of that code can run inside Glide, if you understand what the await calls are doing and how JavaScript promises work. I’m sorry, I do not have time to help you with it.
