How to use GEt and POST methods?

Hi guys!
I’ve searched this theme but didn’t find yet any documentation and I’m new in glide.
Could you please tell me how I could use Post method to send commands on my remote device?
I need to add a few variables on the basic level of the app and embed pretty simple scripts inside the buttons to POST commands.

Thank you for any support in advance!

<html>
<head>
</head>
<body>
<p>
<button type="submit" id="submit1">- 1 -</button>
<button type="submit" id="submit2">- 2 -</button>
<button type="submit" id="submit3">- 3 -</button>
<button type="submit" id="submit4">- 4 -</button>
</p>
<p>
<button type="submit" id="submit5">- 5 -</button>
<button type="submit" id="submit6">- 6 -</button>
<button type="submit" id="submit7">- 7 -</button>
<button type="submit" id="submit8">- 8 -</button>
<button type="submit" id="submit9">- 9 -</button>
</p>
<p>
<button type="submit" id="submit10">- 10 -</button>
<button type="submit" id="submit11">- 11 -</button>
<button type="submit" id="submit12">- 12 -</button>
<button type="submit" id="submit13">- 13 -</button>
<button type="submit" id="submit14">- 14 -</button>
</p>
<script>
var prefix='#>';
var suffix='$\n';
var sim='http://11.111.111.11:1111';
document.querySelector("#submit1").onclick = function(){let response = fetch(sim, {method: 'POST',body: prefix+'01'+suffix});}
document.querySelector("#submit2").onclick = function(){let response = fetch(sim, {method: 'POST',body: prefix+'02'+suffix});}
document.querySelector("#submit3").onclick = function(){let response = fetch(sim, {method: 'POST',body: prefix+'03'+suffix});}
document.querySelector("#submit4").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'04'+suffix
      });
}
document.querySelector("#submit5").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'05'+suffix
      });
}
document.querySelector("#submit6").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'06'+suffix
      });
}
document.querySelector("#submit7").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'07'+suffix
      });
}
document.querySelector("#submit8").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'08'+suffix
      });
}
document.querySelector("#submit9").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'09'+suffix
      });
}
document.querySelector("#submit10").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'10'+suffix
      });
}
document.querySelector("#submit11").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'11'+suffix
      });
}
document.querySelector("#submit12").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'12'+suffix
      });
}
document.querySelector("#submit13").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'13'+suffix
      });
}
document.querySelector("#submit14").onclick = function(){
let response = fetch(sim, {
        method: 'POST',
        body: prefix+'14'+suffix
      });
}
</script>
</body>
</html>

Can you describe more about your use case? I don’t think this is a common case for Glide. It looks like you’re trying to insert some HTML code with functions to do something when a button is clicked from a “remote” UI?

1 Like

Almost as you described. I want to insert HTML code to send a command on a button click event, but send a command outside of glide.

To add the details. I have a device made on the Arduino platform. It has a GSM module with a sim card(allows to receive commands via EDGE). Attached HTML code is an HTML page with 14 buttons. When you click the button, you send the command to the Arduino device so the platform activate the appropriate function. like in a smart house.

1 Like

POST and GET can be achieved (broadly) using the new FETCH column

2 Likes

Would it work if we mimic a “remote” UI in Glide, then each of them sends a webhook to Evgeny’s device?

2 Likes

It’s tricky to understand, but I thought that the requirement was to call an API and potentially get a return value. The API call seems to hit a remote device, instructing it to do something. If so then I think the FETCH might do the job. Not sure.

2 Likes

Hola!

I think you need something like what I did here:
1- Glide with IoT, IIoT (Industrial IoT) and Domotic applications
2- A real notification using Glide and IoT

Take a look at it and let me know if this helps you.

Saludos!

4 Likes